I spent a bit more time this morning thinking about the VersionTask code. I decided that the way that I calculated the Revision Number (a.k.a. PrivatePart of the FILEVERSIONINFO) wasn’t flexible enough. I wanted not only to have a mechanism where I auto-generated that number based on the number of seconds since the start of the day / 10, but I also wanted to be able to increment that number.
It became obvious to me that the ability to increment the revision number becomes important once you ship code. If you’re going to continue to patch existing code by releasing service packs, you need to keep the build number constant, but increment the revision number.
This also requires that you branch the source tree, and I can’t really think of a way to capture that in the NAnt build script automatically. I added the ability to freeze a build number by allowing you to specify “noincrement” for the buildtype attribute. However, you still need to manually specify this in your build file when you branch the source tree to handle revisions to that shipping version.
To support this new feature, I needed to persist the version information structure back to the build.number file regardless of which algorithm you used to generate the build number. However, this also requires that the build.number file get checked into your source control system, and requires your build script to explicitly check out and check back in the build.number file.
I added these new features to the VersionTask.cs file that I shipped yesterday. This file replaces the old file that was there before. Among the things that I did were to clean up some names of methods to more accurately reflect what they did. I now distinguish explicitly between:
-
Version number = major.minor,build.revsion (as a string)
-
Build number = the third octet in the version number
-
Revision number = the fourth octet in the version number
I added ways for you to specify the semantics for the build number:
-
monthday = calculate the build number based on the # months since the start of the project * 100 + the current day of the current month
-
increment = increment the build number each time you build
-
noincrement = freeze the build number - this is used only for cases where you have shipped the code and wish to freeze.
I added ways for you to specify the semantics for the revision number:
-
automatic = calculate the revision number based on the # seconds since the start of the day / 10
-
increment = increment the revision number each time you build during the same day. This assumes that you’re using the monthday build number algorithm. If you’re using the increment build number algorithm, this value is ALWAYS 0 - as it will be if you roll over to a new day in using the monthday algorithm.
Click here to grab the new source file.
1 archived reader comment
rido (2003-11-19)
Do you have unit tests of this Task?
Do you know if there are any plans to include this feature in 0,8.4?
thx in advance
rido