Version numbers consist of two to four components: major, minor, build, and revision. The major and minor components are required; the build and revision components are optional, but the build component is required if the revision component is defined. All defined components must be integers greater than or equal to 0.It's more or less clear about major and minor versions. But what about build and revision? In reality Microsoft uses different approaches e.g.:
The build number is frequently set to increment on a daily basis, either starting at 1 and continuing from there, or as some representation of the date of the build. For Visual Studio 2005, the build numbers are of the form YYMMDD. The revision is typically used to differentiate between multiple builds on the same day, usually starting at 1 and incrementing for each build.Be aware that build numbers based on date have one pitfall. If you set build number e.g. 101228 in visual studio you will get this error message:
You will get similar error if you build project by msbuild. Problem is discussed here.
This was short introduction. Now let me describe how to implement versioning in ccnet.
In my project we use following structure:
- major - major version
- minor - number of sprint in scrum
- build - MMdd
- revision - subversion revision number
We found this format the most handy because it provides all necessary information about a library.
What we have in ccnet? First of all we added svnRevisionLabeller plug-in.This plug-in allows you to get revision number from svn.
ccnet.config
Now in CCNetLabel you will have revision number. We just need to launch msbuild script to update version in AssemblyInfo.cs files e.g. from nant:
updateLibrariesVersion.xml looks as following:
Here we used additional msbuild task called AssemblyInfoTask.