Nuget - Package restore is disabled by default. To give consent, open the Visual Studio Options dialog. (Nuget package restore on a build server)

StackOverflow https://stackoverflow.com/questions/19124055

Question

So, the error I'm getting when my build server builds my project is:

Package restore is disabled by default. To give consent, open the Visual Studio Options dialog.

I'm aware of what this error means and how to resolve it. The problem is I cannot change anything on the build server - my company won't allow it. Additionally, creating an environment variable called EnableNuGetPackageRestore and setting it to true is not an option because that involves modifying the build server.

My question is: is it possible to simply check all of the NuGet packages that are part of a solution into source control so then the build server won't have any reason to go out and re-download them? If so, then perhaps you could explain why this error is still happening, when I've verified that all of the NuGet packages (.nupkg) are in the packages folder in source control:

enter image description here

Second Question: Forgive my ignorance, but what is the reason for the "package restore" feature? Is it to ensure that each package is up to date with the latest version of that package? It seems to me that this "feature" should be a setting that shouldn't hinder building a project on a build server. In my mind, if we want the build server to look for newer packages, then sure, do it, otherwise if I have all my packages in source control and we tell the build server somehow to NOT look for newer packages, that sounds reasonable to me.

Was it helpful?

Solution

So, my situation specifically was I downloaded the source code for the actual Nuget site (to create an internal implementation of Nuget in my company), and when I tried to deploy it, that's when I got the error above.

What I had to do was:

  1. Delete the .nuget folder.
  2. Within your file system (not via Visual Studio), modify the .csproj files (delete where it said <packageRestore>true</packageRestore>, as well as where it imported the project that had nuget.targets in the line - just do a "find" for "nuget.targets", and delete all lines that have an import.
  3. Save your .csproj file changes.
  4. Check in your changes into TFS.
  5. Deploy your solution.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top