I understand that Microsoft uses this template when versioning their products: Major.Minor.Build.Revision. Major is changed when the "developers" want to show that there is a big change in the software and backward compatibility cannot be assumed. Maybe a major rewrite of the code is done. Minor number represents a significant enhancement with the intention of backward compatibility. Build number is a small change, for example a recompilation of the same source. Revision is used to fix a security hole and should be fully interchangeable. Both Build and Revision are optional. This information is based on MSDN Version Class.
The way I version most projects is the same way that Microsoft does, but I increase the Build and Revision each time I build the project. The build number is created this way: MMdd. MM is number of months since the project started and dd is the rest in days. A project started yesterday (25.09.2008) will have this build number to day: 0001. Revision is created this way: HHmm. HH is the hour of the day, and mm is the minute of the hour. It will for example show like this: 1302.
Major and Minor is used much the same as Microsoft suggests. A beta product will have a zero as the Major number.
I often use MSBuild as the build scripting language and I have created a MSBuild task for increasing the build number and revision. It can be downloaded from the link below.
To use it you have to add these lines to your MSBuild file:
<UsingTask TaskName="TFTasks.TFBuildNumber"
AssemblyFile="$(MSBuildStartupDirectory)\tools\treefrog.tasks\TFTasks.dll"/>
<UsingTask TaskName="TFTasks.TFRevisionNumber"
AssemblyFile="$(MSBuildStartupDirectory)\tools\treefrog.tasks\TFTasks.dll"/>
And use the task by doing something like this:
<TFBuildNumber StartDate="09.09.08">
<Output TaskParameter="BuildNum" PropertyName="buildNumber"/>
</TFBuildNumber>
<TFRevisionNumber>
<Output TaskParameter="RevisionNum" PropertyName="revisionNumber"/>
</TFRevisionNumber>
You can then update your AssemblyInfo file by doing something like this:
<Target Name="SetVersionInfo" DependsOnTargets="SetTimeStamp" >
<Attrib Files="@(AssemblyInfoFiles)" Normal="true" />
<FileUpdate Files="@(AssemblyInfoFiles)"
Regex="AssemblyFileVersion\(".*"\)\]"
ReplacementText="AssemblyFileVersion("
$(Major).$(Minor).$(buildNumber).$(revisionNumber)")]" />
</Target>
To get this running, you also need to use the MSBuild Community Tasks. It can be downloaded from tigris.
I posted a question on StackOverflow and asked how people version their projects.
The answers can be found here.
How do you version your projects?
TFTasks-1.0.0927.0.zip (2.48 kb)
Tags: msbuild, continuous integration