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)
I had this when the csproj and sln files were in the same folder (stupid, I know). Once I moved to sln file to the folder above the csproj folder my so
I had the same issue when i reference the Class library into my MVC web application,
the issue was the nuget package version number mismatch between two projects.
ex: my class library had log4net of 1.2.3 but my webapp had 1.2.6
fix: just make sure both the project have the same version number referenced.
Removed below lines in .csproj file
<Import Project="$(SolutionDir)\.nuget\NuGet.targets"
Condition="Exists('$(SolutionDir)\.nuget\NuGet.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)\.nuget\NuGet.targets')"
Text="$([System.String]::Format('$(ErrorText)',
'$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
Is it possible that the packages have been restored to the wrong folder? Check that the paths in the csproj files are correct.
If they are different it could be caused by the packages now being restored to a different location. This could be caused by a NuGet.Config file being checked in specifying a node like this:
<add key="repositoryPath" value="..\..\Packages" />
The packages are being restored, by the projects are still looking at the old location.
The first thing to try is to right-click the solution and select "Restore Nuget Packages".
In my case that did not work, so I followed some recommendations on deleting "Import" and "Target" on project file, this worked for 2 of my 3 projects, but got a different error on the last one.
What worked was to open the Package Manager Console and run:
Update-Package -reinstall -ProjectName MyProjectName
It takes some time but since it reinstall all packages your project will compile without problems
For me it worked as I just copied a .nuget folder from a working solution to the existing one, and referenced it's content!