Using "Clean Sources Plus" for Silverlight Projects
Do you love Jeff Atwood’s (or Coding Horror fame) nifty “Clean Sources Plus” as much as I do? Since I am doing quite a lot of Silverlight work, I often need to zip up a clean version of a project to use an example or for a class. The problem has been that “Clean Sources Plus” does its job too well in one respect and not well enough in another.
One of the files that the utility cleans is the suo file. This would be fine except that the .suo file contains the information on what project is the start-up project. For Silverlight this is confusing because you can actually run the Silverlight project but it often has unpredictable results. Since the web project often has the services and some features of Silverlight do not work under the simple hosting that a Silverlight project has (most notably the ability to stream videos). So I wanted to change the utility to *not* delete the suo file.
The other feature that was missing was that it wasn’t cleaning up the ClientBin directories where the .xap file usually lives. This was less important but helped make the projects nice and small.
To facilitate these changes, luckily the latest version of the utility supports a .config file where you can specify the regex expressions that are used to find files/directories to delete. So I simply changed the config file to remove the .suo file from the deleted files and added the ClientBin to the deleted directories. Thanks Jeff for making this so easy:
<!-- Clean SourcesPlus.exe.config --> <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="DirectoryDeletionPattern" value="^bin$|^obj$|^Debug$|^Release$|^ClientBin$" /> <add key="FileDeletionPattern" value="\.scc$|\.vssscc$|\.user$|\.vspscc$" /> <add key="FileBindingPattern" value="\.(cs|vb)proj$|\.sln$" /> </appSettings> </configuration>
No code change, just a configuration change. Voila. I love it when a plan comes together.