Tutorial :How to Increment Visual Studio build number using C++?


I have a Visual Studio 2008 project that produces a file called: "Game-Release.exe".

This was configured under Project Properties -> C/C++ -> Linker -> General:


I would like to take this a bit further by have an incrementing build number so I would have something which says:


The number on the end should be an incrementing integer. I will be storing the build exe's on subversion so I think i would find this useful (although not necessary).

Perhaps there is a built in macro in Visual Studio that could handle this. Quite possibly I was thinking I could have a text file with the build number in it and have the compiler read, use and increment the number in the file each time the project is built. My goal is however to make the process as automated as possible. What is the best way to accomplish this?

If you offer an opinion, please also provide the code we can all share. Thnx.


The Versioning Controlled Build add-in seems like it would do the job.

Update: Your question specifically mentions using Visual Studio to increment the version, but there is nothing automated about that. Have you considered using Nant and a CI server? That way, it is easy to inject the SVN revision number into AssemblyInfo.cs equivalent for C++. Automatically, on the build server.


If you are using svn to version your project you could follow the instructions in this link it works perfectly for me because I can track bugs in a release application using its version information and comparing the source code.

All information below is not included in the link:

  • setup your rc file like this version.rc

    #include "resource.h"   #include "version.h" //<-----------Don't forget the include  /////////////////////////////////////////////////////////////////////////////  //  // Version.rc  //  VS_VERSION_INFO VERSIONINFO   FILEVERSION VER_FILE_VERSION   PRODUCTVERSION VER_PRODUCT_VERSION   FILEFLAGSMASK 0x17L  #ifdef _DEBUG   FILEFLAGS 0x1L  #else   FILEFLAGS 0x0L  
Next Post »