visual-studionugetnuget-package-restore

Error using nuget in VS2012 "missing packages"


When I build my project from within VS2012 I get the following error message

This project references NuGet package(s) that are missing on this computer. 
Enable NuGet Package Restore to download them. 

I have the nuget options set for NuGet to download missing packages.

picture of nugget options

Yet I still get the error. I have nugget 2.7 installed. With VS2012 update 3


Solution

  • As Dan was alluding to, if your solution has a .nuget folder (from enabling package restore), then nuget 2.7's automatic package restore feature is disabled, as per http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore.

    If automatic package restore is disabled, then any package that installs a project target files will cause your build to fail until you manually restore that package in your solution, as described by http://blogs.msdn.com/b/dotnet/archive/2013/06/12/nuget-package-restore-issues.aspx. (Note that the workarounds described in the link are out-dated now that nuget 2.7 automatic package restore is available.)

    So, if both these things are true, then delete the NuGet.targets file in the .nuget folder, and Nuget will then restore the missing package before invoking MSBuild. You can delete nuget.exe in the .nuget folder as well, as it will no longer be used.