I’ve been using CruiseControl.Net for a while now and use it’s labellers to create version numbers which I then use to label code in VSS and pass to NAnt build scripts which in turn set the assemblies internal version numbers.
There a number of labellers that come already with CC.Net they are:
- Date Labeller
- Default Labeller
- Iteration Labeller
- Remote Project Labeller
- State File Labeller
There is nothing wrong with these labellers, but I quite like the versioning that Visual Studio uses when it builds your applications. Out of the provided labellers the Iteration Labeller came close, but it never seems to work the first time, without having to manually edit the state file. (I’ve had a look at the code and it only generates a version number if the last build status was sucessful. The problem is that it starts off as unknown)
The way that Visual Studio works is that it looks at the value of the AssemblyVersion property in the AssemblyInfo file.
If you have 1.0.*.* it will auto generate the build and revision number of the version.
The build number is calculated from:
(number of months since the project start date * 100) + the number of days from the start of the month.
The revision number is calculated from:
total number of seconds from midnight / 10
There is a NAnt contrib task which does this, but I wanted to get this working in CC.Net to intergrate with VSS better.
I’ve created a custom labeller that you can plugin to CC.Net that mirrors the above functionality.
I found an application called UpdateVersion by written by Matt Griffith and Scott Hanselman (extra feature added by Mike Gunderloy) which is a command line application for generating versions numbers which can be intergrated into VS and NAnt. This had much better code (readablity and less complex) in generating the build and revision numbers than my code (which did work fine).
Thanks also to Martin for the pointers on CCNet plugins.
MS Project Labeller
The MS Project Labeller produces labels that match the version numbers that Visual Studio creates.
<project> <labeller type="msprojectlabeller"> <incrementOnFailure>true</incrementOnFailure> <labelMajor>1</labelMajor>
<releaseStartDate>2005/6/24</releaseStartDate> </labeller> <!-- Other project configuration to go here --> </project>
|incrementOnFailure||Increments label if the previous project status is Failure or Exception||boolean||false||false|
|labelMajor||Major Part of the Label / Version number||int||false||1|
|labelMinor||Minor Part of the Label / Version number||int||false||0|
|releaseStartDate||The date which the build portion of the version number is calculated from||datetime||false||01/01/2000|
Extract zip file and copy dll to the C:Program FilesCruiseControl.NETserver directory
184.108.40.206 (5th May 2006)