Recover disk space by deleting nuget packages not used

When you work for a cosniderable period of time in big projects you realize soon enough that your nuget packages folder for the solution is becoming huge and eating up a lot of your disk space, specially when you update packages, you try some packages and later on decide to not use.

So long story short, I wanted to do some clean up and reclaim some of my precious disk space that was consumed by packages nuget folder.

Here is what I did to recover around 4GB of space.

  1. Go to Visual Studio -> Tools -> Options -> Nuget Package Manager
    Make sure you have checked both options as shown below

  2. Click on "Clear Package Cache" then click "Ok"

  3. Now go to your solution folder and locate the packages folder where it contains all the nuget packages, and delete all the content in there.

Go Back to Visual Studio open your solution and build, it should start to download all the packages again, but only the ones that are used and references by your solution.

Say bye to old packages and say hello to your disk space!