How best to autoincrement build versions?

By default, a new Visual Studio project is version 1.0.0.0, and doesn't change unless you manually change it.  I'd like to increment Build (the last segment) whenever the DLL is regenerated (that is, when the code changes or I choose Rebuild) in a way that can be viewed from Explorer > File > Properties.  If possible/practical, I'm also looking to put some Subversion metadata into a comment (rev, author, check-in date, build-date).

The key is it has to happen automatically when any developer builds a new Release version of a solution.  (Possibly also for Debug versions, but not necessarily.)

I did some searching on StackOverflow and MSDN and found a couple of different techniques.  The standard Microsoft way is via [assembly: AssemblyVersion("1.0.*")], but that's not so attractive because (a) it is generated from date and time of build, not an incrementing version, and (b) AssemblyVersion can't be seen from File:Properties.  I also found a couple of tools which can fiddle with AssemblyInfo.cs, typically invoked by the BeforeBuild script, but those have the disadvantage of changing the number every time, whether the DLL is regenerated or not.  Some also require the developer to have certain parsing tools installed on a specific path so they can be used by all developers.  (We don't have or foresee having a central build environment.)

To ASI: How are build versions assigned for iMIS?  Is it manually updated?  If not, how is it automated?

To solution providers and clients:  Do you have a way to autoincrement the build number?  How have you chosen to manage it?]

--

Bruce Wilson
Director, Technical Services
RSM McGladrey, Inc.
 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Revision, not Build

To be more correct, I'd like to increment the Revision segment.  Major.Minor.Build.Revision.
--
Bruce Wilson
Director, Technical Services
RSM McGladrey, Inc.

We use the * for the last number

And manually increment release numbers.

Anything from ASI?

Any suggestions from ASI?  I can't imagine the process by which you physically assign version numbers is all that proprietary or confidental.

--
Bruce Wilson
Director, Technical Services
RSM McGladrey, Inc.

Internally, we use MS Build

Internally, we use MS Build and a Continuous Integration build system built around it.  We have a custom MSBuild task defined called "GetNextBuildNumber()" which increments the revision number of the existing build and applies it to all the Assemblies and components in the build.  It's a significantly complex build system (multiple cascading builds, each build running automated tests for that "layer" of the build, with the final output being a SETUP.EXE and an installed VM), so I'm not sure it directly translates. 

Needless to say, local builds on development machines don't touch it, it's only the automated CI build process that goes through and updates the version numbers... it gets-latest from TFS into a clean folder, updates the build version with the custom step ensuring that all DLLs and EXEs are properly stamped, does the build, etc, etc.  It may be over-kill for your needs.  Or you may want to avoid using MSBuild.

In a previous life I just used a global search-and-replace utility to update the assembly info line for each assembly to specify the new build number, and that build number was generated automatically with each build.  For small projects, this was done as just simple pre-build steps in Visual Studio, while for larger ones (and non-Microsoft ones), something similar was done via NAnt scripts.

 

Build Version Increment Add-In

There is an Add-In for Visual Studio that may help you:

http://autobuildversion.codeplex.com/