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!
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With