Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable restoring NuGet packages while starting the solution

every time I start my solution (65 projects, UWP, WPF, NetStandard) I can see in my output window (Package Manager) that NuGet is restoring packages. This task needs about 26 seconds. I wonder if this is necessary because why should I want to restore the packages every time I start the solution? It would be great if I could disable it.

I am using Visual Studio 15.2 (26430.16)

Thank you for your help!

like image 877
Portikus Avatar asked Aug 01 '17 12:08

Portikus


People also ask

How do I disable NuGet?

In Visual Studio 2015 onwards, in Tools->Options, NuGet Package Manager->General there is an option "Automatically check for missing packages during build in Visual Studio" which you can turn off.

What does restore NuGet packages mean?

To promote a cleaner development environment and to reduce repository size, NuGet Package Restore installs all of a project's dependencies listed in either the project file or packages. config . The . NET Core 2.0+ dotnet build and dotnet run commands do an automatic package restore.

What is the difference between NuGet restore and dotnet restore?

nuget restore will ensure all of your NuGet dependencies are downloaded and available to your project. Whereas dotnet restore is a complete restoration of all NuGet dependencies as well as references and project specific tools. Meaning that if you run nuget restore , you are only restoring NuGet packages.


1 Answers

The restore you are seeing there is Auto-Restore which will only run on SDK based projects. https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore#automatic-restore-in-visual-studio

There is currently no way to disable auto-restore explicitly but you can disable restore itself. Note that this will disable all restore (on build/rebuild & solution right click restore)

https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore#enabling-and-disabling-package-restore

Go to Tools -> Options -> NuGet Package Manager -> General -> Package Restore. The first option disables restore itself, while the 2nd option disables on build restore.

NuGet tries to restore to make sure that the packages were not deleted from disk or that the assets file (which helps the intellisense) is not deleted. This is integral to the complete visual studio experience. There are improvements in 15.3 (to be released within 2 weeks) that would improve the restore experience on start-up if restore was done at some point previously and if there are no changes to the package references, source etc.

like image 170
imps Avatar answered Sep 20 '22 04:09

imps