22

Good afternoon,

I'm using a SSD and getting close to running out of room. Upon running WinDirStat (great utility!) I've found the biggest remaining HD space hog is the "NuGetScratch" directory, located at:

C:\Users[user name]\AppData\Local\Temp\NuGetScratch\

Based on the name I'm under the impression that this is a swap/temp type file that could probably deleted without any NuGet ill effects. Can somebody confirm this or provide further information? I'm using Window 10 if that matters.

cdahms
  • 3,402
  • 10
  • 49
  • 75
  • The directory corresponding to the one you refer to on both my Windows 7 and Windows 10 drives is empty, and I have used NuGet in VS in both environments. By convention, anything which is not currently in use in a "Temp" directory is fair game for deletion. You did not mention the size of the directory. Had you asked in the correct forum, you would probably have received more information. – Andrew Morton Dec 10 '16 at 18:11
  • Out of interest, mine got to 86gb in about 3 years of dev on my machine – Savage Oct 12 '17 at 09:33

4 Answers4

29

Yes, deleting should be fine.

You can also run NuGet.exe locals temp -clear instead of manually deleting the directory.

For more info, see https://docs.nuget.org/ndocs/consume-packages/managing-the-nuget-cache.

Oskar
  • 7,945
  • 5
  • 36
  • 44
  • 2
    It looks like VisualStudio|nuget are littering huge caching directories under %localappdata%\NuGetScratch. I see a new directory for each new instance of VS I use, and those directories don't go away after closing VS. I now run a scheduled daily task to run that command. It suprises me a lot of other VS/nuget users are not noting this problem. – Bill Hoag Jan 11 '17 at 16:18
  • 3
    Updating Resharper fixed the NuGetScratch [issue](https://github.com/NuGet/Home/issues/4040) – Bill Hoag Jan 11 '17 at 16:43
  • 2
    If anyone gets `unknown command 'locals'` like I was when executing the command, check out [this answer](http://stackoverflow.com/a/34935038/894792) – Luke Apr 12 '17 at 15:54
7

Thanks @BillHoag for the informative link.

For everyone else that wants step by step instructions,

1.) This is a Resharper bug. If you have a version of Resharper that's older than 2016.3.2 , go to https://resharper-support.jetbrains.com/hc/en-us/articles/207242355-Where-can-I-download-an-old-previous-ReSharper-version- and download 2016.3.2.

2.) you can clear out the old files via the Nuget package manager console by going to Tools -> Nuget Package Manager -> Package Manager Console , and typing NuGet.exe locals temp -clear , and pressing enter. May take a good 5 - 10 minutes to finish clearing, but it will do the job.

Garrett Simpson
  • 1,471
  • 2
  • 17
  • 18
2

If you are using the Package Manager Console.

dotnet nuget locals all --clear
0

You can clear all of the cache instead of only temp with the following command to help with other pesky errors that might not be related to the temp cache:

nuget locals all -clear

If you do a nuget locals all --list, this will list all of the caches, not only the temp cache. This lists the http-cache, global-package, and temp caches.

Hopefully this will help someone with that odd error. :)

Keenan Stewart
  • 594
  • 6
  • 9