Skip to content
Latchkey

dotnet nuget locals: Inspect and Clear Caches

dotnet nuget locals lists or clears the local NuGet caches: the global packages folder, the HTTP cache, and the temp folder.

When a cached package is corrupt or a feed change is not picked up, locals is how you inspect and reset the caches.

What it does

dotnet nuget locals operates on the NuGet cache categories: global-packages (extracted packages in ~/.nuget/packages), http-cache (downloaded feed responses), temp, and all. --list prints the path of each; --clear empties it.

Common usage

Terminal
dotnet nuget locals all --list
dotnet nuget locals http-cache --clear
dotnet nuget locals all --clear        # nuke every cache

Options

ArgumentWhat it does
allApply to every cache category
global-packagesThe extracted packages folder (~/.nuget/packages)
http-cacheCached HTTP responses from feeds
tempTemporary files used during restore
-l, --listPrint the location of each cache
-c, --clearClear the selected cache

In CI

Use --list to discover the exact path to cache between runs (~/.nuget/packages on Linux), then key the cache on your lock files. Reach for http-cache --clear when a feed published a fix but restore keeps serving the stale index; avoid all --clear on a cache-restored runner, since it deletes the packages you just restored.

Common errors in CI

NU1403 ("The package content hash validation failed") during restore is the classic corrupt-cache symptom; dotnet nuget locals global-packages --clear (or just the offending package folder) fixes it. If restore keeps resolving an old version after a feed change, clear http-cache. Permissions errors on clear mean the cache path is owned by another user, common when the runner switches users between steps.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →