Getting started with CruiseControl.NET and Subversion

The mini tutorial is designed to show how easy it is to get started with CruiseControl.NET . The aim will be to get a continuous integration build of a Visual Studio 2005 solution including nUnit unit tests running as quickly as possible using Subversion as the source control provider.

As ever the first step is to download it - the version used with this is CruiseControl.NET 1.3, which can be downloaded from:

Grab the CruiseControl.NET-1.3-Setup.exe and CruiseControl.NET-CCTray-1.3-Setup.exe setup kits.

Run the CruiseControl.NET-1.3-Setup.exe installation on the build server - the install is really basic.  Install all the components (CruiseControl.NET Server,Web Dashbord and Examples) make sure to Install CC.NET as Service and also Create Virtual Directory for the Web Dashboard.

While you are downloading and installing grab the XML logger from:

Copy the logger binary (ThoughtWorks.CruiseControl.MSBuild.dll) to the CruiseControl.NET install dierctory (by default C:\Program Files\CruiseControl.NET\server).

Now to configuration, starting with the server...

On the build server checkout a working copy of the Visual Studio 2005 solution to somewhere sensible.  You need to make sure that the build works using MSBuild.exe.  Tghis is best done from the command line - if you don't know msbuild.exe is in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and command line to test will be:

	msbuild path to solution file /t:Clean /p:Configuration=Debug

Make sure the build is successful before moving on!

Now you configure the CruiseControl.NET server...

Open the ccnet.config file found in the server install directory which by default is C:\Program Files\CruiseControl.NET\server.  You are going to create a basic project entry to get tested and running.

<project name="Basic Project">



      <sourcecontrol type="svn">



            <trunkUrl>url to solution directory in subversion</trunkUrl>



            <workingDirectory>solution working directory</workingDirectory>



            <executable>C:\Program Files\CollabNet Subversion Server\svn.exe</executable>









            <intervalTrigger seconds="60" />















                  <workingDirectory>solution working directory</workingDirectory>



                  <projectFile>solution file name</projectFile>



                  <buildArgs>/p:Configuration=Debug /v:diag</buildArgs>









                  <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>















Some points to note in the basic settings above; the sourcecontrol trunkUrl element is the subversion url to the solution, and working directory both in source control and msbuild task are to the local check out directory.  The msbuild element also has the solution file name and paths to the msbuild exe and the logger we downloaded earlier.  The trigger is what fires the build, in this case every minute (if there have been committed changes) the build will run.

The logger is referenced from the copied location, you can exclude the logger path, but you would need to put the logger dll in each project working folder.


Next step is to get the CruiseControl build running using the ccnet.exe (default location C:\Program Files\CruiseControl.NET\server) from the command line:

	ccnet.exe -project:"project name"

All being well (basically if you haven't set anything wrong in the ccnet.config) this should also successfully build.  If not you need to tweak until it does.

So finally to get the unit test running....

The simplest way to get nUnit tests running is to use the nunit task which you configure in the ccnet.config file after the msbuild.  The following is the basic config:



      <path>C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe</path>




            <assembly>path to unit test binary</assembly>







So nothing complex here - the path is the path to the nunit-console.exe, and for each unit test assembly add a full path to the output binary.  Again make sure everything works with the ccnet.exe from the command line, make sure the unit tests pass too, tweaking as needed to get running.   Once its all running smooth then you can start the CruiseControl.NET service.

Finally to monitor the state of the build from the development client, install the CCTray application from the CruiseControl.NET-CCTray-1.3-Setup.exe on each development machine - again a really basic installer.

Following install run cctray and in the File Settings menu select the Build Projects tab and add a Build Server.  You have choices as to which way to monitor the build, I suggest using the "Connect directly using .NET remoting" option supplying server name of the build server - even though the install recommends against this this is the only option which will support the force build option, allowing you to demand a build from the development client.

You will be displayed a list of available project(s), select the available project to monitor - you now have a nice system tray notification showing status of your CI build...

If you want to know more there is plenty to read