Cleanup Temporary Files used by Visual Studio
William Yeack

When building an application, Visual Studio (along with IIS and SQL Server) creates and use a lot of temporary files throughout your system.  Often times, when something is not behaving as expected, it can be caused by old temporary files stuck somewhere in your system.

To fix every possible scenario, I have created the following script to delete every feasible temporary file, so that you can relaunch your application and start anew.



IF EXIST "..\bin" (
RMDIR /s /q "..\bin\"
)

IF EXIST "..\obj" (
RMDIR /s /q "..\obj\"
)

IF EXIST "%LOCALAPPDATA%\Microsoft\VisualStudio\12.0\ProjectAssemblies" (
ECHO Deleting Application Data Cache DEL /S /Q "%LOCALAPPDATA%\Microsoft\VisualStudio\12.0\ProjectAssemblies\")

IF EXIST "%TEMP%" ( ECHO Deleting Temporary Files DEL /S /Q "%TEMP%\")

IF EXIST "%LOCALAPPDATA%\Microsoft\WebsiteCache" ( ECHO Deleting Website Cache DEL /S /Q "%LOCALAPPDATA%\Microsoft\WebsiteCache\")
IF EXIST "%LOCALAPPDATA%\Microsoft\WebsiteCache" ( ECHO Deleting Website Cache DEL /S /Q "%LOCALAPPDATA%\Microsoft\WebsiteCache\")

Just put everything above into a .bat file and run.

Happy coding!

To add a comment, please Register or Login.