Articles in this section

How to clear the NuGet cache in Miscellaneous Extension?

When a new NuGet package is installed, it is stored in the local NuGet cache. Future installations of the same version will reference this cached copy instead of downloading it from the configured package sources. If a package is updated or patched without a version change, it is recommended to clear the NuGet cache before reinstalling the package to ensure that the latest updates are applied.We can clear the NuGet cache locations either using Visual Studio or the command line interface.

1.Using Visual Studio
    • Open Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Settings menu.
    • Click Clear All NuGet Storage button in options dialog then clearing process is started.
    • Once NuGet cache location is cleared, click ok button.

                      

2. Using Command Line Interface

    • Download the latest NuGet executable from here.
    • Navigate the directory of the downloaded exe in command window and run the following command.

OS

Command

Windows

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

Mac

mono nuget.exe locals <all | http-cache | packages-cache | global-packages | temp> -clear

For Example:

Windows:
Command: nuget locals all -clear

NuGet Cache clear form CLI

Mac:
Command: mono nuget.exe locals all -clear

Mac nuget cache clear command

Now the NuGet packages will get removed from cache location.

Note: Clearing the NuGet cache removes all cached packages. After this, every package will be re-downloaded from the source during installation or restore. To avoid clearing the entire cache, you can manually delete only the specific package from the cache location.
Navigate the listed cache locations by file explorer (Windows)/finder (Mac) and remove the unrequired NuGet packages manually.
Windows:
Command:  nuget locals all -list

NuGet Cache location list form CLI

Mac:
Command: mono nuget.exe locals all -list

 Mac nuget cache location list command

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied