Follow @PDSAInc Clean up after Visual Studio - Paul Sheriff's Blog for the Real World

Paul Sheriff's Blog for the Real World

This blog is to share my tips and tricks garnered over 25+ years in the IT industry

Paul's Favorites

Clean up after Visual Studio

As programmer’s we know that if we create a temporary file during the running of our application we need to make sure it is removed when the application or process is complete. We do this, but why can’t Microsoft do it? Visual Studio leaves tons of temporary files all over your hard drive. This is why, over time, your computer loses hard disk space. This blog post will show you some of the most common places where these files are left and which ones you can safely delete.

.NET Left Overs

Visual Studio is a great development environment for creating applications quickly. However, it will leave a lot of miscellaneous files all over your hard drive. There are a few locations on your hard drive that you should be checking to see if there are left-over folders or files that you can delete. I have attempted to gather as much data as I can about the various versions of .NET and operating systems. Of course, your mileage may vary on the folders and files I list here. In fact, this problem is so prevalent that PDSA has created a Computer Cleaner specifically for the Visual Studio developer.  Instructions for downloading our PDSA Developer Utilities (of which Computer Cleaner is one) are at the end of this blog entry.

Each version of Visual Studio will create “temporary” files in different folders. The problem is that the files created are not always “temporary”. Most of the time these files do not get cleaned up like they should. Let’s look at some of the folders that you should periodically review and delete files within these folders.

Temporary ASP.NET Files

As you create and run ASP.NET applications from Visual Studio temporary files are placed into the <sysdrive>:\Windows\Microsoft.NET\Framework[64]\<vernum>\Temporary ASP.NET Files folder. The folders and files under this folder can be removed with no harm to your development computer. Do not remove the "Temporary ASP.NET Files" folder itself, just the folders underneath this folder. If you use IIS for ASP.NET development, you may need to run the iisreset.exe utility from the command prompt prior to deleting any files/folder under this folder. IIS will sometimes keep files in use in this folder and iisreset will release the locks so the files/folders can be deleted.

Website Cache

This folder is similar to the ASP.NET Temporary Files folder in that it contains files from ASP.NET applications run from Visual Studio. This folder is located in each users local settings folder. The location will be a little different on each operating system. For example on Windows Vista/Windows 7, the folder is located at <sysdrive>:\Users\<UserName>\AppData\Local\Microsoft\WebsiteCache. If you are running Windows XP this folder is located at <sysdrive>:\ Documents and Settings\<UserName>\Local Settings\Application Data\Microsoft\WebsiteCache. Check these locations periodically and delete all files and folders under this directory.

Visual Studio Backup

This backup folder is used by Visual Studio to store temporary files while you develop in Visual Studio. This folder never gets cleaned out, so you should periodically delete all files and folders under this directory. On Windows XP, this folder is located at <sysdrive>:\Documents and Settings\<UserName>\My Documents\Visual Studio 200[5|8]\Backup Files. On Windows Vista/Windows 7 this folder is located at <sysdrive>:\Users\<UserName>\Documents\Visual Studio 200[5|8]\.

Assembly Cache

No, this is not the global assembly cache (GAC). It appears that this cache is only created when doing WPF or Silverlight development with Visual Studio 2008 or Visual Studio 2010. This folder is located in <sysdrive>:\ Users\<UserName>\AppData\Local\assembly\dl3 on Windows Vista/Windows 7. On Windows XP this folder is located at <sysdrive>:\ Documents and Settings\<UserName>\Local Settings\Application Data\assembly. If you have not done any WPF or Silverlight development, you may not find this particular folder on your machine.

Project Assemblies

This is yet another folder where Visual Studio stores temporary files. You will find a folder for each project you have opened and worked on. This folder is located at <sysdrive>:\Documents and Settings\<UserName>Local Settings\Application Data\Microsoft\Visual Studio\[8|9].0\ProjectAssemblies on Windows XP. On Microsoft Vista/Windows 7 you will find this folder at <sysdrive>:\Users\<UserName>\AppData\Local\Microsoft\Visual Studio\[8|9].0\ProjectAssemblies.

Remember not all of these folders will appear on your particular machine. Which ones do show up will depend on what version of Visual Studio you are using, whether or not you are doing desktop or web development, and the operating system you are using.

Summary

Taking the time to periodically clean up after Visual Studio will aid in keeping your computer running quickly and increase the space on your hard drive. Another place to make sure you are cleaning up is your TEMP folder. Check your OS settings for the location of your particular TEMP folder and be sure to delete any files in here that are not in use. I routinely clean up the files and folders described in this blog post and I find that I actually eliminate errors in Visual Studio and I increase my hard disk space.

NEW! PDSA has just published a “pre-release” of our PDSA Developer Utilities at http://www.pdsa.com/DeveloperUtilities that contains a Computer Cleaner utility which will clean up the above-mentioned folders, as well as a lot of other miscellaneous folders that get Visual Studio build-up. You can download a free trial at http://www.pdsa.com/DeveloperUtilities. If you wish to purchase our utilities through the month of November, 2011 you can use the RSVP code: DUNOV11 to get them for only $39. This is $40 off the regular price.

NOTE: You can download this article and many samples like the one shown in this blog entry at my website. http://www.pdsa.com/downloads. Select “Tips and Tricks”, then “Developer Machine Clean Up” from the drop down list.

Good Luck with your Coding,
Paul Sheriff

** SPECIAL OFFER FOR MY BLOG READERS **
We frequently offer a FREE gift for readers of my blog. Visit http://www.pdsa.com/Event/Blog for your FREE gift!

Comments

Mike said:

This cleaned up gigabytes of storage on my system (Thanks!). After doing this, VS 2010 will take longer to start on the first startup. Must be rebuilding some of these caches.

# November 9, 2011 9:08 AM

Vince said:

Thank you. I feel much lighter now.

# November 10, 2011 9:25 AM

Marcel said:

I added the folders you mentioned to my list of personal folders in CCleaner. Now every time I do a clean-up, these files get included.

# November 10, 2011 10:26 AM

James said:

Or you could write a simple batch script that goes through and cleans out all unused temp files on the computer. I have had one that I have used for many years and it works on XP and above.  Since most people run as admin in XP (even though it is a bad idea) you can simply run it.  In Vista and 7 it is best to run something like this as Admin so it has the privs to work throughout the computer.

# November 10, 2011 10:41 AM

Marinus van der Wal said:

Usefull article! Thanks.

Kind regards,

Marinus.

# November 10, 2011 10:45 AM

Jacques said:

Intellitrace can eat up a lot of hdd space as well.

# November 10, 2011 11:03 AM

DK said:

This is really stupid -  by doing this you will clear all your customn settings and the visual studio will have the rebuild everything to get you started.

# November 10, 2011 11:35 AM

Stelma said:

Visual Studio is retarded. Windows only.

# November 10, 2011 11:43 AM

psheriff said:

@Mike. Yes, VS will take a little longer next time, but after that it will be fine.

# November 10, 2011 11:48 AM

psheriff said:

@Jacques. I will look into adding Intellitrace to our list of clean up areas. Thanks for the tip!

# November 10, 2011 11:49 AM

psheriff said:

@DK. This does not clear custom settings. That is stored elsewhere.

# November 10, 2011 11:49 AM

Harley Pebley said:

Thanks. Didn't know about all these.

Also, if you're doing unit tests, some test runners also leave behind a "TestResults" sub-folder of the target output directory (typically Debug/bin). I just freed 16GB removing these.

# November 10, 2011 12:19 PM

OfNoConsequence said:

Interesting, I've been using this computer with both VS 2008 and VS 2010 for tools development and dabbling in WP7 development and in all of those locations are empty.

# November 10, 2011 1:19 PM

Mohamed said:

Great article. thank u

# November 10, 2011 3:38 PM

Sofyan_visi said:

It's interesting...my visual studio running more faster.

# November 10, 2011 6:50 PM

Iurii Maistrenko said:

Thank you so much! This is very useful tip which helped me to free a lot of space on my box.

# November 16, 2011 11:50 AM

Andrey said:

Thank you very much!

Cleaning these folders resolved my problem with launching VS on my computer. The problem was that when I tried to start Visual Studio 2010, it began to use 100% of one processor core and hanged.

# March 13, 2012 5:46 AM