Click here to Skip to main content
13,900,411 members
Click here to Skip to main content
Add your own
alternative version


31 bookmarked
Posted 13 May 2003

Add-in for automatically incrementing build numbers in Visual Studio .NET

, 27 May 2003
Rate this:
Please Sign up or sign in to vote.
Finally, an add-in that increments build number for VC++.NET !


The most convenient method I find for automatically incrementing project build numbers for Visual C++ projects is through an add-in that modifies the build number on each successful release build. I found an add-in for doing that at CodeGuru, but it only works for Visual Studio 6.0. I searched a long time for a similar add-in written for Visual Studio .NET but haven't found any. So I wrote one myself, after I did a few days of research about Visual Studio Automation Model.

Advantages of using an add-in over using macros or separate executables:

The first advantage is seamless integration with Visual Studio .NET, thus is not necessary to make custom build steps, pre-link steps or otherwise trigger the build number incrementing. The main advantage of using an add-in is, it uses the Visual Studio .NET automation code model to make modifications to files, thus the development environment is "aware" of the changes and manages them better than an external solution.

So, what does the add-in do ?

On each successful build of a project on a release configuration, the add-in searches for a file included in the project called version.h. Then it searches for one or all of the following macros and modifies their contents in a way described below. The macros that should be present in version.h are (at least one of them is required):


The macros can be placed anywhere in the file. The file can contain other things besides these macros. An example of version.h file:

#define FILE_VERSION         1,0,0,1
#define PRODUCT_VERSION      1,0,0,9
#define FILE_VERSION_STR     "1, 0, 0, 1\n"
#define PRODUCT_VERSION_STR  "1, 0, 0, 9\n"
<!-- end the block of source code -->

After a successful project build on a release configuration, version.h will become:

#define FILE_VERSION         1,0,0,2
#define PRODUCT_VERSION      1,0,0,10
#define FILE_VERSION_STR     "1, 0, 0, 2\n"
#define PRODUCT_VERSION_STR  "1, 0, 0, 10\n"
<!-- end the block of source code -->

Tip: All of these macros can contain any type of string containing at least a decimal number. Only the last number on that string will be incremented. For example, if FILE_VERSION is 1.2, then after build, it will become 1.3.

OK, so how do you use the add-in to increase the build number contained in the version resource?

There is an article on Microsoft Support found here that explains how to do that in a safe way. Basically, you have to cut the version resource from your .rc file and paste it to your .rc2 file. Then replace the values of FILEVERSION and PRODUCTVERSION statements with FILE_VERSION and PRODUCT_VERSION. Then you have to include the file version.h at the top of the version resource.

Add-in installation

  1. Save the file autobuildnumber.dll in a directory.
  2. Run command "regsvr32 autobuildnumber.dll" from the add-in's directory.
  3. Double click the file autobuildnumber.reg.
  4. Go to the Visual Studio .NET IDE, and from Tools->Add-in Manager menu, check the box "AutoBuildNumber". You can also check the boxes "Startup" and "Command line".
  5. Include a version.h file (containing the above macros) in your project.
  6. That's all.


After successfully incrementing build numbers, the add-in displays an output message in the build output window, indicating success. If the version.h file is under source control and is not checked out, the add-in displays an error message in the build output window describing the error. In that case, the build number is not incremented.

The source files are not included. The add-in was built with Visual Studio .NET 2003 and tested on Visual Studio .NET 2002 and 2003. Please e-mail me for support information and source files information.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Catalin Stavaru
Web Developer
Romania Romania
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Morries2-Dec-11 20:55
memberMorries2-Dec-11 20:55 
Questionhow to make version.h file? Pin
Brenda Hatch13-May-09 7:53
memberBrenda Hatch13-May-09 7:53 
GeneralFails to register in Vista Pin
PinballWizard20-Apr-09 19:18
memberPinballWizard20-Apr-09 19:18 
QuestionADD-IN not found Pin
sue_singh1-Nov-07 10:06
membersue_singh1-Nov-07 10:06 
QuestionRe: ADD-IN not found Pin
sue_singh1-Nov-07 10:29
membersue_singh1-Nov-07 10:29 
QuestionSupport for VC8? Pin
TomM15-Mar-06 14:38
memberTomM15-Mar-06 14:38 
Generalvcexpress Pin
hennihenniman7-Mar-05 8:13
memberhennihenniman7-Mar-05 8:13 
QuestionWhere is the add-in's directory? Pin
quinthar20-Feb-05 13:50
memberquinthar20-Feb-05 13:50 
AnswerRe: Where is the add-in's directory? Pin
Catalin Stavaru20-Feb-05 20:30
memberCatalin Stavaru20-Feb-05 20:30 
General'\0' at the end of a string Pin
jlatorref25-Nov-04 2:31
memberjlatorref25-Nov-04 2:31 
GeneralChanging the version.h filename Pin
coferm9-Nov-04 11:43
membercoferm9-Nov-04 11:43 
GeneralHelp to put this add-in working Pin
marcosala30-Aug-04 6:00
membermarcosala30-Aug-04 6:00 
GeneralRe: Help to put this add-in working Pin
Catalin Stavaru30-Aug-04 6:04
memberCatalin Stavaru30-Aug-04 6:04 
GeneralNo source code. Pin
Herbert Yu21-Jun-04 13:46
memberHerbert Yu21-Jun-04 13:46 
GeneralError 80040154 when enabling tool Pin
chrfrenning23-Mar-04 22:06
memberchrfrenning23-Mar-04 22:06 
GeneralRe: Error 80040154 when enabling tool Pin
chrfrenning23-Mar-04 22:10
memberchrfrenning23-Mar-04 22:10 
Generalcustom version info incrementing Pin
mattman6425-Feb-04 6:54
membermattman6425-Feb-04 6:54 
GeneralBuild # for debug builds Pin
TomM28-Nov-03 9:42
memberTomM28-Nov-03 9:42 
GeneralRe: Build # for debug builds Pin
HellesAngel18-Jul-06 23:59
memberHellesAngel18-Jul-06 23:59 
Generalmultiple version statements, build number for debug Pin
Polasek21-Aug-03 3:19
memberPolasek21-Aug-03 3:19 
GeneralSourceSafe checkout Pin
bartman113-Jun-03 7:01
memberbartman113-Jun-03 7:01 
GeneralRe: SourceSafe checkout Pin
laca13-Jun-03 22:51
memberlaca13-Jun-03 22:51 
QuestionWhat is updated? Pin
Sid Price3-Jun-03 6:49
memberSid Price3-Jun-03 6:49 
AnswerRe: What is updated? Pin
Catalin Stavaru3-Jun-03 9:29
memberCatalin Stavaru3-Jun-03 9:29 
GeneralRe: What is updated? Pin
Sid Price3-Jun-03 10:24
memberSid Price3-Jun-03 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190306.1 | Last Updated 28 May 2003
Article Copyright 2003 by Catalin Stavaru
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid