Auto-incrementing build numbers in Visual Studio

Tuesday, March 13th, 2007

One neat feature in Visual Studio I came across today is auto-incrementing build numbers. You can use this to avoid having to configure or write an external tool or version control system just (although you should be using the latter anyway).

To enable it, just open AssemblyInfo.cs in your project, and change the AssemblyVersion setting to [assembly: AssemblyVersion( "1.0.*" )];. Remove the [assembly: AssemblyFileVersion( "1.0.0.0" )]; line entirely; it doesn’t support auto incrementing, and you usually don’t need it in the first place.

The next time you build your project, Visual Studio will put its own values in for the build number and revision number. It’s not too important how it generates these; but if you’re wondering, it uses the number of days since Jan. 1st 2000 as the build number, and the number of seconds since midnight number of seconds since midnight divided by 2 as the revision.

There are 3 comments in this article:

  1. 25/03/2007Ck said:

    Awesome to see a clean solution for doing this… There are plenty of “roll your own” versions floating around suggesting writing your own tool for it, but they are totally off the mark.

  2. 30/03/2007kjeld said:

    Revision is number of seconds since midnight divided by 2. See also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemReflectionAssemblyVersionAttributeClassctorTopic.asp

  3. 3/04/2007Marc Charbonneau said:

    Thanks for clarifying that kjeld.