Setting up CruiseControl.Net with Visual Studio 2010

Continuous integration is amazing. Unfortunately, I have set up continuous integration so many times just hearing those words makes me cry. I always create ccnet instances, forget how I did it, and wind up neck deep in the documentation for 12 hours. I am creating this article to rectify that and hopefully someone will have an easier time configuring their instance next time.

A Little History

For those who haven’t embarked on the journey that is automated builds-continuous integration allows all your code to be integrated continuously. Joking (sorta). Everytime you commit code into your repository continuous integration can get the latest code base, run tests, build the application, publish, and pretty much do whatever else automatically. It will even tell you when a build fails and who the last person was who committed (thus blaming your lazy team member for not committing that dependancy Friday at five before he went home… ass). On to business.

My Configuration and Preferences

Project: Asp.Net MVC 2 with Azure
Deployment Location: Personally hosted IIS7 

I want to setup a staging and qa website off my Asp.Net MVC application. Wenever someone from the team commits I want the stage deployed. Whenever I force a build I would like the qa site deployed. Got that? Automatic stage. Not so automatic QA.

Get Your Dependencies On

I went ahead and installed a copy of Visual Studio 2010 on the continuous integration server which isn’t best practice, but it gave me all the dependencies and a cute editor for the config files.

Azure Note: The Azure SDK requires Visual Studio to be installed and since I am building an Azure product it was another reason I had to opt for the IDE on the continuous integration server.

If you are one of those people who wants to digitally yell me for installing an IDE on a server box note that I really don’t care. I will however shrug off your mean comments and point you in the right direction of configuring your super lean server. You will need the .Net Framework of course, the Windows 7 .Net 4 sdk, Google, and patience. If you aren’t using anything crazy like Azure you should be fine. When you inevitably get target errors find out what MsBuild is looking for and copy the required targets files from your development box to the server.

  • Install a command line version of subversion on the server. I used
  • Install Nant on the server. I used
  • Of course CCNET:

Install Ze Apps

All the items listed above installed without a hitch for me. When I get comments up on the blog you are welcome to ask questions if your installs aren’t going as planned. Nant isn’t an installer so you just unzip it somewhere and make sure the ccnet service has the permissions to access it. You don’t actually have to have Nant I just always end up writing Nant scripts at some point.

Configure IIS

Here you need to create the IIS applications to hold stage and qa. Configuring IIS is outside the scope of this tutorial so if you are unsure consult the internets or your angry system administrator. One key point though: Make sure the continuous integration server has access to copy the final build to the IIS installation.

Finally, the Configurations

First thing is open the ccnet.config file located in the Cruise Control.Net installation. I am putting my first project in there with a twist. Change it to this:

My ccnet.config files get very large once I start adding multiple projects. This is a way to tell ccnet “Dude, use this configuration for this project. PS. It is in this other file.” Go ahead and add the ProjectConfigs folder that is referenced to the same directory. This is where we are going to put all of our configurations. Go into the directory and add the projectname.config file. Set it to this:

Ok, so what I did here was create the project. Working and artifact directories are standard ccnet configurations for where everything is and where ccnet can do some temporary work. The source section is pretty straight forward saying my repository is here. The trigger is saying “Check for modifications every minute and if someone changed anything rebuild it all.”

The msbuild section is building under my stage build configuration after cleaning everything thus building the entire solution. The extra parameters automatically adjust the web.config and make a publish. Finally, the deployment section moves it all over to the staging environment. YAY!


The QA build configuration is much easier to create.

  1. In the ccnet.config add another entry for the second project. 
  2. Create ProjectConfigs/myprojectqa.config and copy the stage.config contents to it. 
  3. Remove the triggers so that the project must be force-built.
  4. Make the necessary adjustments to the build configurations (In my case create another build configuration for QA that builds with the web deployment project and change the /p:Configuration=QA) 
  5. Change where the project gets deployed

If you made it this far thanks for reading the article. I hope it helped you out with this extremely powerful, but for some reason extremely tedious to configure tool.