Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget cache vs global packages folder

Tags:

.net

nuget

I am trying to understand the difference between the two. This article says:

The cache avoids downloading a package that's already been installed on the machine.

The global packages folder allows multiple projects to share the same installed package, thereby reducing NuGet's overall footprint on the computer.

This article says a bit more.

When asked to retrieve a package, NuGet first looks in the global-packages folder. If the exact version of package is not there, then NuGet checks all non-HTTP package sources. If the package is still not found, NuGet looks for the package in the http-cache unless you specify --no-cache with dotnet.exe commands or -NoCache with nuget.exe commands. If the package is not in the cache, or the cache isn't used, NuGet then retrieves the package over HTTP.

Why so many lookups, why multiple places to keep packages locally? What am I missing?

like image 560
Robotronx Avatar asked Nov 06 '22 23:11

Robotronx


1 Answers

Global packages folder used to store dependency installations (unpacked nuget packages and nupkg file). When multiple projects use the same dependency they wont download and unpack the dependencies if it is already exists in this location.(If they are using PackageRefence. )

Htpp-cache used to store downloaded nuget packages for a short duration(30 minutes). The only time that I think this will be usefull; when a package removed from global packages folder and a project tries to restore the same package it will be fetched from http-cache instead of a remote nuget repository.

As for non-Http sources; You can define a folder in your computer as a nuget repository. This location will contain nukpg files. And nuget can use this location as a nuget packages source.(like local nuget repository)

like image 125
miskender Avatar answered Nov 15 '22 11:11

miskender