Click here to Skip to main content
15,798,278 members
Articles / Operating Systems / Windows

Continuous Integration with CruiseControl

Rate me:
Please Sign up or sign in to vote.
3.21/5 (10 votes)
27 Apr 2007CPOL10 min read 59.6K   45   21
Walks you through setting up a CruiseControl Build server with various tools


A Continuous Integration server is a must have for any developer that wishes to increase productivity and become a better developer. In general, it gives you a good constant working copy of your application all the time. Specifically, it pinpoints problems as soon as you check in the code. It is like having another developer whose full time job is just compiling and checking your code for errors.

I am a sole developer in my full time job, and I do side work at home. Anyone who says a build server is ONLY for a team is full of it. Like I said above, having a build server is like having another developer there helping you out and pointing out problems.

There are many options for software when it comes to Continuous Integration. I use CruiseControl because:

  1. It is the most popular in the open source community. 
  2. It's fairly easy to setup.

Though this article may feel a little overwhelming with all the tools at hand, and I guarantee that you will have problems setting up various build files and getting all your tools to play nice, in the long run it is all worth it 1000 times over.

To get a basic understanding of how CruiseControl works, take a look at this image here. That should give you an idea of how the whole process works.

Here are the steps of the process:

  1. You check your code into your SCM.
  2. Your build server checks your SCM every 60 seconds for changes.
  3. When a change is detected, the source code is checked out by the build server to a local directory where it is compiled by NAnt.
  4. After compilation is complete, you can then run any number of tools that output XML files to be picked up by CruiseControl.
  5. CruiseControl merges XML output with its output to produce the website results.
  6. Voila!


First, you need a dedicated box that will be your build server. It doesn't need to be a work horse, but it needs to be a little decent. At home I have an old EMachine with 512MB RAM running Windows XP and it works just fine. You will also need to install IIS and the .NET Framework SDK.

Once you have that set up, we can get into setting up the file system.

1. Create a Base Directory for All the Tools

The base directory I always use is C:\CI\. I also create a directory where all your projects will be located at. Ideally this should be outside of your CruiseControl root, by default CruiseControl buries your projects within the server directory which I personally don't like. My Projects root path C:\CI\Projects\.

2. Download and Install the Tools


Choose to setup the IIS virtual directory. Once installed, you can choose to install CCTray which installs an application on your local machine system tray that will periodically check the build server for broken builds. For some reason after installing cruise control, I had to go to Services and manually enable the CruiseControl Service, it wasn't automatically started.

Subversion/Source Control Access

I use Subversion, you need to have it installed so CruiseControl can grab the latest checked in code from your source code repository. If you would like to use visual sourcesafe, then there is a cruise control config for that as well as many other types of source control systems supported by CruiseControl.

CCNetConfig (thanks to Camalot Designs in the comments below)

I have not personally tried this tool yet, but as Camalot states in the comments below, it is a GUI tool for creating and editing your ccnet configuration files. One of the hardest parts of the whole cruisecontrol/nant process is setting up the XML configuration files, this should make that portion much easier.


When it comes to building your projects you can use either MSBuild or NAnt. The only problem with using NAnt is that it cannot currently build solution (*.sln) files. This makes it much more difficult to do the entire build process with NAnt. I'm sure it can be done, but I personally never went down that route. So instead the method I used, is to have an NAnt task kick off an MSBuild. This is where nant-contrib comes in below. The MSBuild task can build your main solution file.


To setup NAnt-Contrib, simply copy all the assemblies from NantContrib\bin into NAnt\bin. Or you could just register the NAntContrib\bin into your PATH. NAnt-Contrib has additional NAnt tasks that people have contributed over time. A couple of them are quite useful like the <nunit> task and <msbuild> task.


Performs unit testing on your test project using nunit-console.exe and outputs to the artifacts directory.


Checks your tests for code coverage. This MSI doesn't give you the option of the path to install to, so once you install it you should move it to your CI directory.

NCoverExplorer/NCoverExplorer Extras

This outputs a very nice NCover output page with pretty bar graphs and such.
It allows for a much better overall look of your code coverage rather than the standard text output that ncover will give you in cruise control. NCoverExplorer Extras has NAnt tasks for building the nice ncoverexplorer output. In order to set this up, simply copy NCoverExplorer.NAntTasks.dll into your NAnt\bin directory and nant will find the tasks at runtime.

Follow the instructions in NCoverExplorer.Extras\CruiseControl.Net\readme.txt which will tell you where to place the XSL files for cruisecontrol to pick them up so you get the nice output.


Checks your code for acceptable patterns & practices guidelines. (I personally use this one with a grain of salt, although it has proven useful.)

Add files to your PATH Environment Variable

At the minimum, add the NAnt\bin\ folder to your path, it's up to you to add other tools to your path. It will make it easier in the long run to setup nant build files.

Once you are done with all of these steps, restart your computer to ensure all your applications are setup correctly and your PATH is refreshed.

3. Configure Cruise Control

Open C:\CI\\server\ccnet.config, this file has all of your projects for cruise control to monitor. It also has settings for what <task> to run when a change has been found in one of your projects, i.e.:


Next, restart the CruiseControl service to pick up the changes we made to ccnet.config and then fire up the cruise control website and make sure our project shows up. Your project root folder should now contain a complete checkout of the code from the repository.
This is what CruiseControl will use to look for changes at whatever intervals you defined in ccnet.config.

If your code is not checked out, then you can go to "View Server Log" on the webpage to see what the problem is. Once Cruise Control sees the new project, it will make the project folder and artifacts directory and then automatically connect to your source control store and download the latest source code to the "trunk" folder.

At this point, you should be able to go to your cruise control server via a Web browser. Your project should be showing up even if it does say "fail" or "unknown", since we haven't setup our build file yet. If this isn't the case, then check all the options above before going any further because it just gets more tricky.

Now, the best piece of advice I used while learning to use NAnt, is create a *.bat file to JUST run your *.build file. This will eliminate CruiseControl out of the picture until you are sure that your project builds correctly. Then you can go ahead and try to automate the build through CruiseControl. This helps in eliminating other unknowns as well.

I usually place it in C:\CI\Projects\startnant.bat, and change the build file to run before I add a new project to cruise control so I can be sure that everything is working correctly with NAnt.

Here is a sample *.bat file:

nant.exe c:\ci\projects\united\

Now for the file. This is the whole shebang. Basically the easiest way to read it is look for:

<target name="all" depends="clean,get,build,tests,reporting" />

This is the order that the tasks will run in. So the tasks will run in the order:
clean - get - build - tests -reporting.

At any point if one of them fails, it will stop execution unless you have told it: failonerror="false", in which case it will continue execution.

The attached file can pretty much be used for any project, just change the properties at the top to match your configuration and drop it in the project root. Then test it out with the BAT file you created before.

You'll notice that I have commented out the FxCop section at the end. This is because at the time of writing, I had not yet setup an FxCop project, but wanted to show you how to configure that section.

So at this point, you should be able to run your BAT file and see the build complete and generate a bunch of output files under the Project\artifacts\ directory. This leads us to the next section.

The last thing we have to do is tell CruiseControl to "merge" this output with its own so that the results are displayed in the cruisecontrol website.

To do this, open your ccnet.config under C:\CI\CruiseControl.NET\server\ and add the following lines:

  <xmllogger />

Place this within your <project> node. This will merge all XML files, and a file named CoverageReport.xml into CruiseControls output.

You should now go to your Web console for CruiseControl, force a build and watch it complete. Then you can browse into the project and view all of the different reports.

Points of Interest

You WILL bang your head against the wall when trying to get this to work the first time. It took me 2 days to get it to compile the first time. Mainly because I had a poor project folder structure. With the improper folder structure, it makes it more difficult to build the solution in one shot. I would suggest making a "SharedLibs" folder in your project root to house all dependencies. This way you don't have to place them in certain areas on the build server every time you change assemblies. All of your assemblies will be in source control, under your project root. Sounds weird because you duplicate files in Source Control, but this is the easiest and suggested way to do it because you can then change dependencies on the fly.

As I said in the beginning, this is a MUST have for any developer. Team or not. It has increased my productivity and just from the simple fact of when my boss comes to me asking to see a working copy of the project, I just copy the latest source from the build server. That by itself is worth its weight in gold.

All of these tools combined are very powerful, and thanks to CruiseControl we can pull them all together in one easy to use interface. The setup is a little daunting and took me quite a while to get down to how everything works together. The key here is to read all the documentation on all the tools. Especially NAnt and CruiseControl. The power of NAnt is much further reach than what I have described here. The build file I posted is just a very basic build file to get you started. You can do many more things with nant so make sure you read the docs!

I hope this article was helpful to someone. I have been meaning to write it for a while, and I had to setup another build server at home and took the time to write this article as I stepped through the process.



  • 4/28/2007 - Article first published
  • 4/29/2007 - Added the CCNetConfig tool information courtesy of Camalot Designs. Thanks!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionHello!can you help me?my Dashboard can not show NCover report Pin
baibin36991-Mar-12 16:52
baibin36991-Mar-12 16:52 
GeneralLaunching an Exe Pin
mmcguirk130-Aug-10 10:35
mmcguirk130-Aug-10 10:35 
QuestionIntegrating NCoverExplorer in CruiseControl.NET? Pin
ppayal5-Apr-08 22:31
ppayal5-Apr-08 22:31 

I am using for continuous integration for my project. I want to integrate NCoverExplorer also in it.

In my project I have created separate project for all unit tests and and separate project for the code to be unittested.

How should I change my file to integrate NCoverexplorer in it?

Any help?

Regards. Pin
Member 41799573-Dec-07 19:07
Member 41799573-Dec-07 19:07 
GeneralCI Factory Pin
jflowers19-Jun-07 15:36
jflowers19-Jun-07 15:36 
GeneralWhy CI Pin
Jef_Patat25-May-07 0:13
Jef_Patat25-May-07 0:13 
Generalsample config files Pin
poodull761-May-07 4:00
poodull761-May-07 4:00 
GeneralRe: sample config files Pin
dgroves7-May-07 6:51
dgroves7-May-07 6:51 
GeneralRe: sample config files Pin
Sean Chambers7-May-07 11:51
Sean Chambers7-May-07 11:51 
GeneralRe: sample config files Pin
dgroves7-May-07 12:32
dgroves7-May-07 12:32 
GeneralRe: sample config files Pin
Sean Chambers7-May-07 15:45
Sean Chambers7-May-07 15:45 
GeneralMSBuild won't build vdproj's Pin
Bernhard Hofmann30-Apr-07 22:48
Bernhard Hofmann30-Apr-07 22:48 
GeneralRe: MSBuild won't build vdproj's Pin
Sean Chambers1-May-07 2:10
Sean Chambers1-May-07 2:10 
GeneralOne more tool to help with CruiseControl Configuration Pin
ryanconrad28-Apr-07 7:12
ryanconrad28-Apr-07 7:12 
GeneralRe: One more tool to help with CruiseControl Configuration Pin
Sean Chambers28-Apr-07 12:05
Sean Chambers28-Apr-07 12:05 
Questiondo i need dedicated box as a build server? Pin
WissamK28-Apr-07 5:03
WissamK28-Apr-07 5:03 
AnswerRe: do i need dedicated box as a build server? Pin
ryanconrad28-Apr-07 7:04
ryanconrad28-Apr-07 7:04 
AnswerRe: do i need dedicated box as a build server? Pin
Sean Chambers28-Apr-07 12:09
Sean Chambers28-Apr-07 12:09 
GeneralRe: do i need dedicated box as a build server? Pin
WissamK29-Apr-07 3:02
WissamK29-Apr-07 3:02 
GeneralRe: do i need dedicated box as a build server? Pin
Sean Chambers29-Apr-07 6:50
Sean Chambers29-Apr-07 6:50 
Answerit's better yes Pin
SoTTo30-Apr-07 14:48
SoTTo30-Apr-07 14:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.