This project references NuGet package(s) that are missing on this computer
I have an ASP.NET MVC5 application that worked yesterday and now I am getting this error when I try to build:
This project references NuGet package(s) that are missing on this computer.
I have the two options checked that allow nuget to automatically download and install missing packages checked / turned ON. I have also tried deleting all of the files in the packages folder and then have nuget re-download them. Also when I open nuget and look for updates it says there are none that need to be installed. I can't figure what else to do to move beyond this amazingly annoying issue.
In my case, I had to remove the following from the .csproj file:
<Import Project="$(SolutionDir).nugetNuGet.targets" Condition="Exists('$(SolutionDir).nugetNuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir).nugetNuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir).nugetNuGet.targets'))" />
</Target>
In fact, in this snippet you can see where the error message is coming from.
I was converting from MSBuild-Integrated Package Restore to Automatic Package Restore (http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore)
One solution would be to remove from the .csproj file the following:
<Import Project="$(SolutionDir).nugetNuGet.targets" Condition="Exists('$(SolutionDir).nugetNuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir).nugetNuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir).nugetNuGet.targets'))" />
</Target>
How?
In my case it happened after I moved my solution folder from one location to another, re-organized it a bit and in the process its relative folder structure changed.
So I had to edit all entries similar to the following one in my .csproj
file from
<Import Project="..packagesMicrosoft.Bcl.Build.1.0.14toolsMicrosoft.Bcl.Build.targets" Condition="Exists('..packagesMicrosoft.Bcl.Build.1.0.14toolsMicrosoft.Bcl.Build.targets')" />
to
<Import Project="packagesMicrosoft.Bcl.Build.1.0.14toolsMicrosoft.Bcl.Build.targets" Condition="Exists('packagesMicrosoft.Bcl.Build.1.0.14toolsMicrosoft.Bcl.Build.targets')" />
(Note the change from ..packages
to packages
. It might be a different relative structure in your case, but you get the idea.)
上一篇: NuGet下载所有软件包,不更新引用