Global Packages and Cache Folders
|
This section documents MSBuild 18.9, the .NET SDK 10.0.402 (with its This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The C# Reference bibliography lists the reference material consulted while preparing these pages. |
NuGet keeps four folders per user: the global-packages folder where restored packages live, the HTTP cache of downloaded feed responses, a temp folder and a plugins cache. Knowing where they are — and which one to clear — solves most "stale package" problems and is the basis of CI caching. This page uses NuGet 7.9.0 (.NET SDK 10.0.402) on Linux.
The folders
dotnet nuget locals all --list on a fresh profile:
http-cache: ~/.local/share/NuGet/http-cache
global-packages: ~/.nuget/packages/
temp: /tmp/NuGetScratchroot
plugins-cache: ~/.local/share/NuGet/plugin-cache
| Folder | Contents | Override |
|---|---|---|
global-packages |
Every restored package, extracted: |
|
http-cache |
Raw feed responses and |
|
temp |
Scratch files during restore and install |
|
plugins-cache |
Results of credential-provider and other plugin discovery |
|
NUGET_PACKAGES=/srv/nuget/packages NUGET_HTTP_CACHE_PATH=/srv/nuget/http \
NUGET_SCRATCH=/srv/nuget/tmp NUGET_PLUGINS_CACHE_PATH=/srv/nuget/plugins \
dotnet nuget locals all --list
http-cache: /srv/nuget/http
global-packages: /srv/nuget/packages
temp: /srv/nuget/tmp
plugins-cache: /srv/nuget/plugins
CI systems cache the global-packages folder (keyed on lock files) by pointing NUGET_PACKAGES at a path inside the
workspace (CI Builds and Caching).
Clearing
dotnet nuget locals http-cache --clear
dotnet nuget locals global-packages --clear
Clearing NuGet HTTP cache: ~/inst-http
Local resources cleared.
Clearing NuGet global packages folder: ~/inst-gp
Local resources cleared.
(here with the two folders redirected to a scratch location; the global-packages folder was removed entirely). Which one to clear:
-
A package was re-uploaded under the same version on a private feed — the global-packages folder (restores never re-download an existing version) and the HTTP cache.
-
A just-published version is not found — the HTTP cache, or
--no-http-cachefor one restore: the feed’s version list may be cached for up to 30 minutes. -
Everything —
dotnet nuget locals all --clear; the next restore downloads every package again.
Clearing fails with "being used by another process" when an IDE or build server holds files (close them, run
dotnet build-server shutdown), and with "Access to the path is denied" when the folders were created by another
user — the result of mixing sudo and normal builds
(Environment Variables, Completion and Telemetry).
Cleaning old packages
The global-packages folder only grows. NuGet offers half of a cleanup: the updatePackageLastAccessTime setting makes
every restore touch the .nupkg.metadata of each package it uses, so their timestamps show what is still in use:
<config>
<add key="updatePackageLastAccessTime" value="true" />
</config>
NuGet has no command to delete the unused ones; community tools do it. A cleanup must delete a package’s
.nupkg.metadata first — restore treats a folder with that file as a complete package. Restores of projects that
are already up to date do not touch the timestamps, so wait some days after enabling the setting.
Fallback folders
fallbackPackageFolders in nuget.config (or the RestoreFallbackFolders property) lists read-only folders in the
global-packages layout that restore checks before downloading — once used for the offline package cache that early
.NET Core SDKs shipped. A package found there is used in place, not copied. They are rarely needed today; an offline or
air-gapped build is better served by a local feed
(Package Sources and Source Mapping).
Source: nuget.config: fallbackPackageFolders.