VS.NET 2003: MACRO - Cleanup temp web folder when closing
This problem has got to annoy at least someone as much as it annoys me:
- You close a Web project and open another than has a similar folder structure
- You attempt to create a folder that existed in the previous web project but not in the new one.
- Visual Studio tells you that the folder already exists
- You swear and delete everything in c:\Documents and Settings\[Username]\VSWebCache\[ComputerName]
- You close and open the project
- You create the folder
To solve this annoying problem, I came up with an EnvironmentEvents macro a while back that cleans up the VSWebCache folder when you close a solution that contains a web project. To implement, paste the code below into a EnvironmentEvents macro module.
Private PerformCleanup As Boolean
Private Sub SolutionEvents_AfterClosing() Handles SolutionEvents.AfterClosing
If (PerformCleanup) Then
Dim psi As New ProcessStartInfo("cmd", "/C rmdir /Q /S ""%homedrive%%homepath%\VSWebCache\%computername%""")
psi.CreateNoWindow = True
System.Diagnostics.Process.Start(psi).WaitForExit()
psi = New ProcessStartInfo("cmd", "/C mkdir ""%homedrive%%homepath%\VSWebCache\%computername%""")
psi.CreateNoWindow = True
System.Diagnostics.Process.Start(psi).WaitForExit()
End If
End Sub
Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
Dim isWebProject As Boolean = False
Dim prj As Project
For Each prj In DTE.Solution.Projects
If (prj.Properties.Item("ProjectType").Value = 1) Then
isWebProject = True
Exit For
End If
Next
PerformCleanup = isWebProject
End Sub