Project Templates, or "How to Become Classless"
One side effect of TDD seems to be a moderate to gargantuan increase in the number of projects in one's solution. And with almost half of those being Test projects, it was with no small amount of gratitude that I tracked down Steven Rockarts' post on creating a project template with references to NUnit and Rhino.Mocks built-in.
One of the things Steven did when creating his template is something that has become automatic for most of us. To wit, the first step in creating a class library is to delete Class1.
So after creating my project template (which by the way, required me to go to Tools | Customize, then the Commands tab, File menu to add the Export Template... menu item to the IDE first), I got to thinking that maybe I'd create my own Class Library template which doesn't include Class1.
But being a forgetful Hillbilly, I would inevitably forget to use my template the first couple of times and creating a class library would take longer as I'd have to go through the extra stages of deleting my new project, cursing, then creating a new one with my template.
Better to modify the master. Which on my machine, is located at: C:Program FilesMicrosoft Visual Studio 8Common7IDEProjectTemplatesCacheCSharpWindows1033ClassLibrary.zip
Once there, I did the following:
- Deleted class1.cs
- Opened classlibrary.csproj in a text editor and deleted the <Compile> element that referenced Class1.cs in the last <ItemGroup> element
- Opened csclasslibrary.vstemplate in a text editor and deleted the <ProjectItem> that referenced Class1.cs in the <Project> element at the bottom
Now my class libraries are created free of Class1.
In addition to this, I also went to C:Program FilesMicrosoft Visual Studio 8Common7IDEProjectTemplatesCSharpWindows1033 and made the same modifications to the contents of the ClassLibrary.zip file. I'm not 100% certain but I think this is necessary if you ever need to re-install the VS templates (using devenv.exe /installvstemplates), which I did have to do earlier today when my Web User Control template stopped appearing in my list.
In an even more ideal world, creating a class library would automatically prompt you for the name of your first class, doing nothing if you leave it blank. Haven't found a feature like that in ReSharper but I can't imagine this isn't possible in some third-party tool somewhere.