Reputation: 355
I read on Microsoft Documentation https://learn.microsoft.com/it-it/nuget/consume-packages/managing-the-global-packages-and-cache-folders :
Whenever you install, update, or restore a package, NuGet manages packages and package information in several folders outside of your project structure
So, if I install Bootstrap Package for my solution MyFirstSolution
the package should be downloaded on my folder global-packages
and a reference to it will be added on my solution.
If everything is right when i create MySecondSolution
and want to add Bootstrap VS should only add a reference to my project but technically I have to download it again from the package manager not only add a reference to the existing package downloaded for MyFirstSolution
.
At the same time whenever I download a project by third part I have to reinstall all the packages used even if I already have installed it from other project made by me.
Upvotes: 3
Views: 1599
Reputation: 8359
Here is the output of the Package Manager when I installed Newtonsoft.Json 13.0.1
that was already installed in another project (ie: in cache):
Restoring packages for D:\Sources\github\Orace\SO\SO_72936295\SO_72936295.csproj...
Installing NuGet package Newtonsoft.Json 13.0.1.
Writing assets file to disk. Path: D:\Sources\github\Orace\SO\SO_72936295\obj\project.assets.json
Successfully installed 'Newtonsoft.Json 13.0.1' to SO_72936295
Executing nuget actions took 247 ms
Time Elapsed: 00:00:00.7045858
========== Finished ==========
Time Elapsed: 00:00:00.0864676
========== Finished ==========
Here is the output of the Package Manager when I installed FluentAssertions 6.7.0
that was never installed on my machine (ie: not in cache):
Restoring packages for D:\Sources\github\Orace\SO\SO_72648958\SO_72648958.csproj...
GET https://api.nuget.org/v3-flatcontainer/fluentassertions/index.json
OK https://api.nuget.org/v3-flatcontainer/fluentassertions/index.json 136ms
GET https://api.nuget.org/v3-flatcontainer/fluentassertions/6.7.0/fluentassertions.6.7.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/fluentassertions/6.7.0/fluentassertions.6.7.0.nupkg 23ms
GET https://api.nuget.org/v3-flatcontainer/system.configuration.configurationmanager/index.json
OK https://api.nuget.org/v3-flatcontainer/system.configuration.configurationmanager/index.json 137ms
GET https://api.nuget.org/v3-flatcontainer/system.configuration.configurationmanager/4.4.0/system.configuration.configurationmanager.4.4.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/system.configuration.configurationmanager/4.4.0/system.configuration.configurationmanager.4.4.0.nupkg 19ms
GET https://api.nuget.org/v3-flatcontainer/system.security.cryptography.protecteddata/index.json
OK https://api.nuget.org/v3-flatcontainer/system.security.cryptography.protecteddata/index.json 150ms
GET https://api.nuget.org/v3-flatcontainer/system.security.cryptography.protecteddata/4.4.0/system.security.cryptography.protecteddata.4.4.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/system.security.cryptography.protecteddata/4.4.0/system.security.cryptography.protecteddata.4.4.0.nupkg 17ms
Installed System.Configuration.ConfigurationManager 4.4.0 from https://api.nuget.org/v3/index.json with content hash gWwQv/Ug1qWJmHCmN17nAbxJYmQBM/E94QxKLksvUiiKB1Ld3Sc/eK1lgmbSjDFxkQhVuayI/cGFZhpBSodLrg==.
Installed System.Security.Cryptography.ProtectedData 4.4.0 from https://api.nuget.org/v3/index.json with content hash cJV7ScGW7EhatRsjehfvvYVBvtiSMKgN8bOVI0bQhnF5bU7vnHVIsH49Kva7i7GWaWYvmEzkYVk1TC+gZYBEog==.
Installed FluentAssertions 6.7.0 from https://api.nuget.org/v3/index.json with content hash PWbow/R3MnYDP8UW7zh/w80rGb+1NufGoNJeuzouTo2bqpvwNTFxbDwF6XWfFZ5IuquL2225Um+qSyZ8jVsT+w==.
Installing NuGet package FluentAssertions 6.7.0.
Writing assets file to disk. Path: D:\Sources\github\Orace\SO\SO_72936295\obj\project.assets.json
Successfully installed 'FluentAssertions 6.7.0' to SO_72936295
Successfully installed 'System.Configuration.ConfigurationManager 4.4.0' to SO_72936295
Successfully installed 'System.Security.Cryptography.ProtectedData 4.4.0' to SO_72936295
Executing nuget actions took 43 ms
Time Elapsed: 00:00:01.5080716
========== Finished ==========
Time Elapsed: 00:00:00.1262123
========== Finished ==========
As you can see, in the second case there is actually some downloads (like: GET https://api.nuget.org/v3-flatcontainer/fluentassertions/index.json
).
In both cases, there is a Writing assets file to disk.
part.
That is the actual installation of the NuGet in your project.
If you manually edit the .csproj
to add the NuGet, this part still need to be executed.
You do it by the contextual menu of the solution root item in the Solution Explorer.
Click Restore NuGet Packages
.
Upvotes: 3