This past week I was playing around with Hudson and Team City and getting some NAnt scripts put together to use. In a happy coincidence I happened to catch a mention about Tree Surgeon from twitter and it had piqued my curiosity. Tree Surgeon is a project on CodePlex that has been around for a while and helps automate the process of setting up a source tree and assembling build scripts. It was just what I was looking for.
The goal of Tree Surgeon was to make setting up and laying out new projects using best practices dead simple. All the major tools and libraries that typically find their way into your .Net source trees are provided for you. In addition to laying out the directory structure for your source and libraries, a solution file gets created with three main projects to get you started. The basic project setup includes a console app, core library and unit test project. The build scripts come pre-wired to have NCover run your tests and generate reports from the results and also do things like packaging your build artifacts into zip files for deployment.
The whole process, start to project generated, is very easy. Download and run the installer. Launch the program, select the version of Visual Studio (2003, 2005, and 2008) and the flavor of testing framework (NUnit or MbUnit) and then hit generate. The files and directories, built out in your Documents folder, are then created and ready to be used.
There are two slight issues I ran into that I’d like to point out. Both issues had already been noted in the project forums and were easy to fix. When generating a source tree with MbUnit selected as the unit test framework, the build script generated has the unit test assembly referenced is named incorrectly. You will have to change it to match your project’s unit test assembly name. The second issue has to do with running NCover and NUnit on x64 machines. I found that in order for NCover and NUnit to work on x64 machines I had to add two calls to the CorFlags utility to make executables work. This was accomplished by making the modifications to the “˜run-unit-tests’ target below on lines 5-8.
Even though I am pretty late to the party with Tree Surgeon I am very happy to have stumbled across it. The whole source tree and build script setup process is the perfect thing to script out and I am really glad the project creator and contributors have taken the time to do this. It is a big help and I highly recommend you try it out the next time you are spinning up a new source tree for a project.