How to clear a specific NuGet package from the local cache using the command line?

Question

Can I flush a specific NuGet package from the local NuGet cache using the command line?

Context

I would like to make sure that when I perform the package restore operation for the project, the most recent server binaries will be restored, and not something from the cache. At the same time, I do not want to delete all packages from the cache.

+4
source share
1 answer

If you have version NuGet.exe version 3.3 or higher, you can clear the entire cache from the command line:

nuget locals <all | http-cache | packages-cache | global-packages> -clear

If your NuGet packages are loaded into the NuGet v2 cache, you can simply create a simple script to remove a specific .nupkg file from the package cache.

del %LocalAppData%\NuGet\Cache\NUnit.2.6.4.nupkg

NuGet v3 , :

rmdir %UserProfile%\.nuget\packages\NUnit\2.6.4 /s
+6

All Articles