How can I clear the NuGet package cache using the command line?

dotnet nuget locals all --clear

If you're using .NET Core.


The nuget.exe utility doesn't have this feature, but seeing that the NuGet cache is simply a folder on your computer, you can delete the files manually. Just add this to your batch file:

del %LOCALAPPDATA%\NuGet\Cache\*.nupkg /q

First, download the NuGet command line tool from here.

Next, open a command prompt and cd to the directory to which nuget.exe was downloaded.

You can list the local caches with this command:

nuget locals all -list

You can clear all caches with this command:

nuget locals all -clear

Reference: https://docs.nuget.org/consume/command-line-reference


In Visual Studio 2017, go to menu ToolsNuGet Package ManagerPackage Manager Settings. You may find out a button, Clear All NuGet Cache(s):

Enter image description here

If you are using .NET Core, you may clear the cache with this command, which should work as of .NET Core tools 1.0:

dotnet nuget locals all --clear