63

I get a message saying the following:

Error 1 Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'.

When I go to Tools -> Options, I do not see Package Manager and underneath I see Package Sources and Recent Packages. I do not see anywhere where I can set Allow Nuget to download missing packages during build though.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Nate Pet
  • 44,246
  • 124
  • 269
  • 414

4 Answers4

69

The option to give consent in the UI has been added with NuGet Package Manager 1.8. It's the 3rd item under Tools-> Options-> Package Manager-> General : "Package Restore : Allow NuGet to download missing packages during build".

Please make sure NuGet is up-to-date in Tools->Extension Manager.

Alternatively you can give consent by setting the EnableNuGetPackageRestore Environment variable to true.

chepner
  • 497,756
  • 71
  • 530
  • 681
Alexandre Dion
  • 9,130
  • 2
  • 41
  • 29
  • 13
    Updating nuget fixed the problem – Zenuka Jul 11 '12 at 08:16
  • I had to use the environment variable after doing everything else and it still didn't work. (admittingly i had it disabled, had packages folder checked into svn and then deleted it, so maybe I had other corrupt state) – JDPeckham Sep 22 '12 at 21:50
60

I found I needed an extra couple of steps to get it to download the packages

  1. Check Allow NuGet to download missing packages during build

  2. Check Always show solution in Projects and Solutions

  3. Right click on solution and Enable NuGet Package Restore

  4. Open Manage NuGet Packages and click Restore

svick
  • 236,525
  • 50
  • 385
  • 514
Tom
  • 12,591
  • 13
  • 72
  • 112
  • 5
    I don't have that context menu item for "Enable NuGet Package Restore" showing up in the Solution context menu - I have the latest version of NuGet (2.0.30717.9005) installed in VS 2012. Has anyone had this problem? – Guy Starbuck Sep 25 '12 at 22:09
  • 1
    +1 I didn't have that first menu itme either. Nevertheless clicking Restore solved the issue. – surfen Oct 08 '12 at 10:52
  • It is good advice to visit Manage NuGet Packages and click `restore`! – Boris Parfenenkov Apr 24 '14 at 10:01
  • Like Guy Starbuck - I too do not have the option shown above. Also, no button 'Restore' in yellow bar appears in the Manage NuGet Packages section - yet I still get the error described by OP. Why does MS keep changing stuff so versions of the same tool exhibit different behaviors and differing verbiage - harder than hell to search for a solution... – barrypicker Aug 20 '14 at 16:29
2

I did not seem to have the "Package Manager" node under Tools->Options [this was in Visual Studio 2013 :-)]. To get that node in there, I browsed to Tools -> Extensions and Updates and searched for nuget. Installing "NuGet for Visual Studio 2013" got me the node and the option to allow package restore!

Sudhanshu Mishra
  • 6,523
  • 2
  • 59
  • 76
1

I am using Visual Studio 2010 and NuGet 2.0.

Someone had checked in a solution that used NuGet for various packages. When I checked out the solution and built it, I got the same errors. What's more, when I viewed the NuGet Package Manager from the Tools -> Options window, the Package Restore already had the appropriate check boxes checked.

I tried clicking the Clear Package Cache button. After doing that, everything built correctly.

enter image description here

Jeremy Ray Brown
  • 1,499
  • 19
  • 23
  • this worked for me on VS2012, both checkboxes were already checked, but clearing the package cache immediately resolved the error and allowed me to build. thanks! – SelAromDotNet Jan 22 '15 at 17:39