Let CruiseControl.NET take care of the heavy lifting!
Automating your daily and nightly builds is the most effective process one can take from the agile methodology processes and procedures. It is also very easy to setup and configure. Once you have it in place, it is on rare occasions when you have to make edits or upgrades to the build process. You can almost say it is as easy as, set it and forget it.
CruiseControl.NET automates your automation of the build process. Download the executable from Source Forge and run the executable on the server where the build process will be run from.
Ok things to note:
The configuration file for CruiseControl.NET lives here C:\Program Files\CruiseControl.NET\server\ccnet.config and this is where you will tell CruiseControl.NET what tasks in the build process to monitor and at what intervals to run at and who to notify when the task is either successful or broke.
There are 2 types of tasks that can be run from the ccnet.config file. First is run directly which special commands that are built right into CruiseControl.NET and the other is calling NAnt build script to run external tasks. You have a lot more flexibility with writing build tasks in NAnt.
ccnet.config – cruise control internal tasks
This task checks subversion for any edits or updates to the server every 120 seconds. If one is found then CruiseControl.NET compiles the solution making sure that the code introduced did not break the build.
<project name="Build">
<labeller type="defaultlabeller" />
<webURL>http://localhost/ccnet/ViewFarmReport.aspx</webURL>
<sourcecontrol type="filtered">
<sourceControlProvider type="svn" autoGetSource="true">
<executable>C:\Program Files\VisualSVN Server\bin\svn.exe</executable>
<trunkUrl>http://domain.com/svn/ProjectName/trunk</trunkUrl>
<workingDirectory>D:\Projects\compile\ProjectName\trunk</workingDirectory>
<tagOnSuccess>false</tagOnSuccess>
<tagBaseUrl>http://domain.com/svn/ProjectName/tags</tagBaseUrl>
<username>rmartin</username>
<password>********</password>
</sourceControlProvider>
<inclusionFilters>
<pathFilter>
<pattern>**/*.*</pattern>
</pathFilter>
</inclusionFilters>
</sourcecontrol>
<triggers>
<intervalTrigger name="continuous" seconds="120" buildCondition="IfModificationExists" />
</triggers>
<publishers>
<merge>
<files>
<file>C:\Program Files\CruiseControl.NET\server\Build\Artifacts\results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
<email
from="ProjectNameBuild@domain.com"
mailhost="mail.domain.com" includeDetails="TRUE">
<users>
<user name="Ryan Martin" group="buildmaster" address="rmartin@domain.com"/>
<user name="Some Guy" group="buildmaster" address="sguy@domain.com"/>
</users>
<groups>
<group name="buildmaster" notification="always"/>
</groups>
</email>
</publishers>
</project>
ccnet.config – nant external tasks
This task is an external task which is run by a nant build script that lives potentially on the build server. You can have your build script wherever you choose but I like to have it with the project and all of its dependencies (documentation, binaries, database scripts and build scripts and reports).
<project name="Deploy-To-Development">
<labeller type="defaultlabeller" />
<webURL>http://localhost/ccnet/ViewFarmReport.aspx</webURL>
<sourcecontrol type="filtered">
<sourceControlProvider type="svn" autoGetSource="true">
<executable>C:\Program Files\VisualSVN Server\bin\svn.exe</executable>
<trunkUrl>http://domain.com/svn/ProjectName/trunk</trunkUrl>
<workingDirectory>D:\Projects\compile\ProjectName\trunk</workingDirectory>
<tagOnSuccess>false</tagOnSuccess>
<tagBaseUrl>http://domain.com/svn/ProjectName/tags</tagBaseUrl>
<username>rmartin</username>
<password>Madison1</password>
</sourceControlProvider>
<inclusionFilters>
<pathFilter>
<pattern>**/*.*</pattern>
</pathFilter>
</inclusionFilters>
</sourcecontrol>
<tasks>
<nant>
<executable>D:\Projects\compile\ProjectName\trunk\binaries\nant\bin\nant.exe</executable>
<baseDirectory>D:\Projects\compile\ProjectName\trunk\source\</baseDirectory>
<buildArgs>-D:svn.executable="D:\Projects\compile\ProjectName\trunk\binaries\subversion\svn.exe"</buildArgs>
<nologo>false</nologo>
<buildFile>D:\Projects\compile\ProjectName\trunk\Build\ProjectName.build</buildFile>
<targetList>
<target>deploy-to-development</target>
</targetList>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<merge>
<files>
<file>C:\Program Files\CruiseControl.NET\server\Deploy-To-Development\Artifacts\results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
<email
from="ProjectNameBuild@domain.com"
mailhost="mail.domain.com" includeDetails="TRUE">
<users>
<user name="Ryan Martin" group="buildmaster" address="rmartin@domain.com"/>
</users>
<groups>
<group name="buildmaster" notification="always"/>
</groups>
</email>
</publishers>
</project>
ProjectNameWeb.build – nant build script
This script has endless capabilities. There is an extensive set of commands you can call within nant scripts that are specific to nant build process. The command such as exec, echo, delete and copy are easy to learn and understand and most of all extremely powerful in helping cut down on development time by automating everyday remedial tasks.
<?xml version="1.0" encoding="utf-8"?>
<project name="IpswitchftWeb" default="build" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
<!-- Properties -->
<property name="devserver.website.dir" value="D:\Projects\www\ProjectName"/>
<property name="trunk.dir" value="..\" />
<property name="source.dir" value="${trunk.dir}\Source" />
<property name="msbuild.exe" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe" />
<property name="solution.sln" value="${source.dir}\ProjectNameWeb.sln" />
<!-- Called Externally -->
<target name="build" depends="compile" />
<target name="deploy-to-development" depends="compile, deploy.to.development" />
<!-- Coding Tasks -->
<target name="compile">
<exec program="${msbuild.exe}" commandline="${solution.sln} /t:Rebuild /v:q" />
</target>
<target name="deploy.to.development">
<echo message="Deleting all files in development web directory"/>
<delete verbose="true">
<fileset basedir="${devserver.website.dir}">
<include name="*.*" />
</fileset>
</delete>
<echo message="XCopy files to development web directory"/>
<copy todir="${devserver.website.dir}" includeemptydirs="false" overwrite="true">
<fileset basedir="${ProjectNameWeb.dir}">
<exclude name="**/obj/**"/>
<exclude name="**/*.csproj"/>
<exclude name="**/*.csproj*"/>
<exclude name="**/App_Data*"/>
<exclude name="**/App_Data*/**"/>
<exclude name="**/.svn*"/>
<exclude name="**/.svn*/**"/>
<include name="**"/>
</fileset>
</copy>
</target>
</project>
CruiseControl.NET Web Dashboard
This is a web interface to view and run CruiseControl.NET configuration file. From here you can run any task configured in your ccnet.config file and view the results.
This web page url defaults to the localhost setting but you will be viewing it from your local machine like other developers so you must change localhost with the server name: http://servername.domain.com/ccnet/ViewFarmReport.aspx