In a previous post I introduced a tiny utility to clean up Visual Studio projects. I have introduced minor fixes to it since then, so this is the most recent version, which also deletes *.suo and *.user files and produces a report of all the files and folders that couldn't be deleted for any reason:
Imports
Module
' delete any .suo and vbproj.user file For Each dir As String In dirNames Dim files As New List(Of String) files.AddRange(Directory.GetFiles(dir, "*.suo")) files.AddRange(Directory.GetFiles(dir, "*.user")) For Each fileName As String In files Try Console.Write("Deleting {0} ...", fileName) File.Delete(fileName) Console.WriteLine("DONE") Catch ex As Exception Console.WriteLine() Console.WriteLine(" ERROR: {0}", ex.Message) errorsList.Add(fileName & ": " & ex.Message) End Try Next Next
You can download the binary version here: VSProjCleaner.exe (24 KB) or the complete solution here: VSProjCleaner_Source.zip (15.08 KB)
Using this tool couldn't be simpler: just run it from the command window and pass a folder name as an argument, enclosing it in double quotes if it contains spaces: VSPROJCLEARNER "c:\my projects\testproj"The tool recursively visits all the folders and deletes all BIN and OBJ directories, and deletes *.suo and *.user files. At the end of the process it lists all the folders and files that couldn't be removed, if any.
DISCLAIMER: I have tested this code against my own projects and it always worked correctly, but I don't should be held responsible for any loss of important files (for example, a .user file that has nothing to do with a Visual Studio project.). For this reason, I urge you to apply this tool only to a COPY of your projects
Remember Me
Powered by: newtelligence dasBlog 1.8.5223.1