Build numbers: major.minor.revision

Viewed 29873

How would you write a build.xml file, using neither custom code nor external dependencies (such as a shell script), that:

  • Generates a build number of the form major.minor.revision (e.g., 01.02.34).
  • Auto-increments the revision on each compile of the source code.
  • Auto-increments the minor version on each execution of a dist(ribution) task.

Additionally:

  • Provides an option to increment the major number.
  • Provides an option to increment the minor number.
  • Whenever the major number is incremented, the minor and revision numbers are set to 0.
  • Whenever the minor number is incremented, the revision number is set to 0.

Bonus:

  • Creates a variable based on the git revision number (like a subversion revision number).

Clarification:

  • Automatic checkout (or commit) is not required.
  • Integration with Subversion is not desired.

Thank you for any examples. Here are some related sites that describe how to perform similar tasks:

7 Answers

This was a while ago, so this is from memory:

I build a custom CruiseControl.Net labeller block that ticked up the build number on each build. It maintained an XML file with all 4 components of the version number and identified each project by name (so it could support multiple projects).

The four values it generated get passed to the build process (nAnt, in our case), which had the responsibility of tweaking all the AssemblyInfo.cs files to reflect the proper build number.

Edited to note: The only value that get automatically ticked up was the build number. Major/Minor version numbers were specified in the CC.Net project configuration. The build number restarted at 0001 for each change in major or minor revision number (e.g., if you went from version 7.1 to version 7.3, for instance, the 7.1 build might be at build number 783, but the first 7.3 build started with build number 1; the next 7.1 build would be build 784.

Change version numbers merely required tweaking 1 setting the CC.Net config file.

Related