Introduction
Nant is used as a building service. MsBuild is another option, but these settings aren’t discussed here.
We have several scripts for the build process in Nant. You will see that only a few things must be changed in the scripts when adding another project.
The total package of all NAnt scripts will be available over several posts, so be sure that you read all my upcomming posts also. At the end you will have a fully automatic working buildserver
.
To use Nant in CruiseControl.Net, we have to change the ccnet.config file (see the ccnet.config file in chapter 3). Here is the new ccnet.config:
<cruisecontrol>
<project
name="ProjectX"
webURL="http:\\localhost\ccnet"
workingDirectory="C:\Buildserver">
<sourcecontrol type="vss" autoGetSource="true" applyLabel="false">
<executable>C:\Program Files\Microsoft Visual SourceSafe\Common\Vss\template\win32\SS.EXE</executable>
<project>$/Projects\ProjectX\xxxxx.ProjectX</project>
<username>VSSUser</username>
<password>VSSPws</password>
<ssdir>\\path to VSS DB\SourceDB</ssdir>
<workingDirectory>Buildserver\ProjectX</workingDirectory>
<cleanCopy>true</cleanCopy>
</sourcecontrol>
<tasks>
<nant>
<executable>Tools\Nant\bin\nant.exe</executable>
<buildArgs>"-D:outputType=Xml"</buildArgs>
<nologo>false</nologo>
<buildFile>Projects\ProjectX\ProjectXSolution\xxxxx.ProjectX\master.build
</buildFile>
<targetList>
<target></target>
</targetList>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</nant>
</tasks>
</project>
</cruisecontrol>
As you can see we refer to the master.build file of our first project. Later this will be changed to all.build in the Buildscripts.
Buildscripts
OK let's start with our buildscripts. As you can see Nant uses a Buildscript to know which projects to build and in which order (all.build – will be our general script in a later phase). For each project there is also a project bound script (master.build). In this build file, we define which files are needed to build that specific project. As first step we will refer to the master.build for one project so we can test if our buildserver is working correctly.
Here's an example of a master.build file :
<?xml version="1.0" encoding="utf-8"?>
<project name="xxxxx.ProjectX" default="xxxxx.ProjectX.Build" xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">
<!-- #################################################### -->
<!-- Settings -->
<!-- #################################################### -->
<property name="project.type" value="library" />
<property name="project.FormalName" value="xxxxx.ProjectX" />
<property name="project.build.dir" value="${bin.intern.dir}" />
<property name="project.output" value="${project.build.dir}\${project.FormalName}.dll" />
<property name="rootNamespace" value="xxxxx.ProjectX" />
<property name="src.dir" value="${src.root.dir}\${project.FormalName}" />
<property name="project.define" value="${vbc.define}" />
<include buildfile="../generictargets.build" />
<!-- #################################################### -->
<!-- Project xxxxx.ProjectX-->
<!-- #################################################### -->
<target name="xxxxx.ProjectX.Compile" description="Compile project">
<csc target="${project.type}" output="${project.output}" debug="${vbc.debug}" define="${project.define}">
<sources>
<include name="${src.dir}\AssemblyInfo.cs" />
<include name="${src.dir}\Class1.cs" />
</sources>
<references>
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Xml.dll" />
<include name="${project.build.dir}/xxxxx.ProjectY.dll" />
</references>
</csc>
</target>
<!-- #################################################### -->
<!-- Start -->
<!-- #################################################### -->
<target name="xxxxx.ProjectX.Build">
<call target="xxxxx.Version" if="${project.version}" />
<call target="xxxxx.ProjectX.Compile" />
<call target="xxxxx.DEV" if="${build.type.deploy}" />
<call target="xxxxx.TST" if="${build.type.deploy}" />
<call target="xxxxx.PRD" if="${build.type.deploy}" />
</target>
</project>
In our next chapter we will show you how you can create the master.build file automaticly.
Overview Buildserver chapters on my blog :
Chapter 1 : Introduction
Chapter 2 : CruiseControl.Net
Chapter 3 : Projects
Chapter 4 : Project Structure
Chapter 5 : NAnt and all our buildscripts