As I said in my last entry, I wanted to begin setting up my environment for the
Virtual Cellar using Continuous Integration. A free software package that does
that for me is CruiseControl.Net
I downloaded
CruiseControl.Net version 0.6.1 and unzipped it to my D:\Program Files\CruiseControl.Net
folder.
Configuring Cruise Control
As you recall I'm using Subversion
for my source code provider and NAnt for my
build tool. At a minimum this is what I need to get cruise control working.
Editing the ccnet.config file
The default installation of cruise control comes with a D:\Program Files\CruiseControl.Net\server\ccnet.example.config
configuration file. I removed a lot of the information from this file, and
tailored it to work with
my installation of Subversion.
<cruisecontrol>
<project name="VirtualCellar">
<webURL>http://localhost/ccnet</webURL>
<schedule type="schedule" sleepSeconds="60"/>
<sourcecontrol type="svn">
<executable>D:\program files\subversion\bin\svn.exe</executable>
<trunkUrl>file:///D:/Svn/VirtualCellar/trunk</trunkUrl>
</sourcecontrol>
<build type="nant">
<executable>D:\Program Files\nant-0.84\bin\nant.exe</executable>
<baseDirectory>D:\Build\VirtualCellar</baseDirectory>
<buildFile>default.build</buildFile>
<targetList>
<target>build</target>
</targetList>
<buildTimeoutSeconds>300</buildTimeoutSeconds>
</build>
</project>
</cruisecontrol> |
As you can see, I've named my project "VirtualCellar". We'll skip the <webUrl>
entry for now, as I haven't yet setup the website. <schedule> node tells
cc.net to check for changes in the <sourcecontrol> every 60 seconds. (This
is probably too short for me, but I'll leave it set that way for now).
I've also setup the <sourcecontrol> node to use Subversion and
pointed it to my installation of the subversion program files. In addition, I
need to point to the trunk (or root) of my Virtual Cellar project in the
Subversion repository. CC.Net supports many different types of source control
programs.
CC.Net and NAnt
I next need to tell CC.Net how I plan to build my application. As you may
recall I've
installed and
configured my Virtual Cellar project to be built with Nant. I do this
by pointing to the NAnt executable (I moved it since my last installation from
d:\nant-0.84 to d:\program files\nant-0.84, I also need to check into using
environment variables rather than hard coded paths).
I need to tell CC.Net where to build the continuous integration version
of the Virtual Cellar project. When I setup Subversion, I
chose D:\VirtualCellar for "my working
copy". I don't want CC.NET to use that folder because that's *my* project and I
may have files that I'm working on that aren't checked in to Subversion. So, I
have to setup a working folder for Subversion. Normally CC.Net would run on a
dedicated Build Server, but for now I'm running it on my dev machine.
So, in
looking back at
my Subversion post, I need to create a build folder and then checkout the
latest version of the VirtualCellar project to that folder. The following box
shows the result. You can see all the work I've done so far, I have my
documentation, two projects (Lorengo.VirtualCellar.Business and Tests) along
with their associated .csproj and NAnt build files.
D:\>md build
D:\>cd build
D:\build>svn checkout file:///d:/svn/VirtualCellar/trunk VirtualCellar
A VirtualCellar\VirtualCellar.sln
A VirtualCellar\default.build
A VirtualCellar\Doc
A VirtualCellar\Doc\rup
A VirtualCellar\Doc\rup\02Elaboration
A VirtualCellar\Doc\rup\01Inception
A VirtualCellar\Doc\rup\01Inception\VirtualCellar.BusinessCase.doc
A VirtualCellar\Doc\rup\01Inception\VirtualCellar.Vision.doc
A VirtualCellar\Lorengo.VirtualCellar.Business
A VirtualCellar\Lorengo.VirtualCellar.Business\AssemblyInfo.cs
A VirtualCellar\Lorengo.VirtualCellar.Business\Cellar.cs
A VirtualCellar\Lorengo.VirtualCellar.Business\default.build
A VirtualCellar\Lorengo.VirtualCellar.Business\Lorengo.VirtualCellar.Business.csproj
A VirtualCellar\Lorengo.VirtualCellar.Business\Wine.cs
A VirtualCellar\Lorengo.VirtualCellar.Business.Tests
A VirtualCellar\Lorengo.VirtualCellar.Business.Tests\AssemblyInfo.cs
A VirtualCellar\Lorengo.VirtualCellar.Business.Tests\default.build
A VirtualCellar\Lorengo.VirtualCellar.Business.Tests\Lorengo.VirtualCellar.Business.Tests.csproj
A VirtualCellar\Lorengo.VirtualCellar.Business.Tests\CellarFixture.cs
Checked out revision 9. |
When all is said and done I now have another working copy of my Virtual
Cellar project for CC.Net in the D:\Build\VirtualCellar folder. This is what I
set as my <baseDirectory> and point to the default.build file as my <buildFile>.
The <target> tells NAnt which target in the build file to build, for now I have
2 targets, "clean" and "build" (which is dependent on "clean"). I'll be adding
more targets going forward but for now I'll use the "build" target.
And that's it! I'll save this file as ccnet.config
Running CruiseControl.Net
All that is left to do is run the cruise control server, here's the output...
D:\Program Files\CruiseControl.Net\server>ccnet
[CruiseControl Server:Info]: CruiseManager: Listening on tcp://192.168.1.100:21234/CruiseManager.rem
[CruiseControl Server:Info]: Starting CruiseControl.NET Server
[CruiseControl Server:Info]: Reading configuration file "D:\CruiseControl.Net\server\ccnet.config"
[CruiseControl Server:Info]: Starting integrator for project: VirtualCellar
[VirtualCellar:Info]: Starting integration for project: VirtualCellar
[VirtualCellar:Info]: 25 modifications detected.
[VirtualCellar:Info]: Building
[VirtualCellar:Info]: Build complete: Success
[VirtualCellar:Info]: Integration complete: 9/27/2004 7:23:25 PM
[VirtualCellar:Info]: No modifications detected.
...(more of same deleted)...
[VirtualCellar:Info]: No modifications detected.
[VirtualCellar:Info]: 1 modification detected.
[VirtualCellar:Info]: Building
[VirtualCellar:Info]: Build complete: Success
[VirtualCellar:Info]: Integration complete: 9/27/2004 7:49:37 PM
|
The first time it runs it knows that it hasn't built anything so it detects
all of the changes so far and runs the build successfully (Yeah!). I'll now go
ahead and add a new test to the CellarFixture.cs class. Here's what it looks
like in Windows Explorer with TortoiseSVN installed.

You can see that the CellarFixture.cs is flagged as up to date, here's what
it looks like after I modify it with a new test, and then save the file.

It's flagged as being different or updated. It isn't until I right+click on
the file and say "Commit" from the TortoiseSVN context menu that the file is
committed to Subversion. (Of course I've compiled and tested it on my machine
before I do this so I don't "break the build"). Once I commit my changes, Cruise
control detects the change (every 60 seconds for now), and issues the build with
another Success! As my project grows and takes more time to build, I'll probably
want to change the schedule to every hour or so...
That's it! I've got a integration server that will now build when changes to
the repository are detected. I can now continue with more development. Of course
there are other things that I'll want to add to my continuous integration
pipeline, like automagicall running NUnit (or MbUnit) tests, FxCop rules, and
eventually creating an install package. Ahh! what the future holds.
Odds and Ends - MSBuild with NAnt
In my
Refrigerators, Unit Testing and NAnt post Kirk
Maple asked about using MSBuild with NAnt, one possible solution would be to
do the following...
<target name="build">
<sysinfo />
<exec program="PathToMSBuild\MSBuild.exe"
commandline="MyProject.csproj" />
</target> |
Seeing as I didn't install the Team System Yet, I don't have MSBuild on
my machine, so Your Mileage May Vary.