Dec 15 2009

Compile your solution with and without MSBuild via CruiseControl.NET

Category: Continuous Integrationryancmartin1976 @ 20:57

First Strategy:

Second Strategy:

Compiling your solution every time subversion has a new commit

There are 2 ways to compile a solution in CruiseControl.NET, with MSBuild and without. I use both, one, without, is very simple process and runs every time a new file is committed to Subversion.

Compiling without MSBuild in ccnet.config

<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>

Compiling with MSBuild in my nant build script

<?xml version="1.0" encoding="utf-8"?>
<project name="ProjectNameWeb" 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" />
 
  <!-- Coding Tasks -->
  <target name="compile">
    <exec program="${msbuild.exe}" commandline="${solution.sln} /t:Rebuild /v:q" />
  </target>
</project>

Seeing the results

Launch the CruiseControl.NET from Programs -> CruiseControl.NET -> CruiseControl.NET from the server where you installed CruiseControl.NET. The software will run the tasks in the configuration file you setup in ccnet.config

I recommend using the windows service which runs continuously and does all of the automation for you based off of the interval trigger you setup in the file as well. The interval triggers are task specific.

And lastly you can force builds and view the result in the CruiseControl.NET Web dashboard.

Tags: , , , ,