In the last month I started working again a lot on CruiseControl and build processes.
Another quick tip I think it's interesting to share is how to have the version number of the code you are building synchronized with the build number generated by CruiseControl.NET.
As everything related to build processes inside CC.NET this is achieved using a NAnt task: asminfo.
Step 1 - CC.NET Labeler
The first thing you have to setup is the labeler inside the ccnet.config file:
<labeller type="defaultlabeller"> <prefix>2.2.0.</prefix> <incrementOnFailure>False</incrementOnFailure> </labeller>
This will instruct CC.NET to prefix the build label with the major.minor.revision of your product.
Step 2 - Setup solution AsseblyInfo.cs file
Next step is to add a VersionInfo.Designer.cs as solution file and link it in all the project of your solution: now you will have the same version in all the assembly produced by the build.
using System; using System.Reflection; [assembly: AssemblyVersionAttribute("2.2.0.0")]
This file will be overridden on the build server with the right version number, but when developer compile on their local machine, then the build number will always be 0, so it will be easy to identify "official" builds from the local ones.
Step 3 - NAnt build script
Last step, add the following task inside the NAnt build script
<asminfo output="VersionInfo.Designer.cs" language="CSharp"> <imports> <import namespace="System" /> <import namespace="System.Reflection" /> </imports> <attributes> <attribute type="AssemblyVersionAttribute" value="${CCNetLabel}" /> </attributes> </asminfo>