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
dotnet nuget locals all --list
dotnet nuget locals http-cache --clear
dotnet nuget locals all --clear # nuke every cacheOptions
| Argument | What it does |
|---|---|
| all | Apply to every cache category |
| global-packages | The extracted packages folder (~/.nuget/packages) |
| http-cache | Cached HTTP responses from feeds |
| temp | Temporary files used during restore |
| -l, --list | Print the location of each cache |
| -c, --clear | Clear 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.