How to increase Visual Studio build number using C ++?

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

This has been configured in Project Properties -> C / C ++ - > Linker -> General :

$(OutDir)\$(ProjectName)-Release.exe 

I would like to take this a little further by adding an incremental build number so that I have something that says:

 Game-Release-Build-1002.exe 

The number at the end must be an incrementing integer. I will keep the exe assembly in subversion, so I think I would find it useful (although not necessary).

There may be a built-in macro in Visual Studio that can handle this. Quite possibly, I thought that I could have a text file with the build number in it and read the compiler, use and increase the number in the file every time the project was built. My goal, however, is to make the process as automatic as possible. What is the best way to do this?

If you express an opinion, please indicate the code that we can all provide. Thnx.

+4
source share
5 answers

The Versioning Controlled Build Add-in seems to do the job.

Update: Your question specifically mentions using Visual Studio to increase the version, but there is nothing automated about this. Have you considered using Nant and CI server? Thus, it is easy to enter the SVN version number in the equivalent of AssemblyInfo.cs for C ++. Automatically on the build server.

+3
source

If you use svn for the version of your project, you can follow the instructions in this link , it works fine for me, because I can track errors in the release application using its version information and comparing the source code.

All information below is not listed in the link:

  • configure your rc file like this version of .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 #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040704b0" BEGIN VALUE "CompanyName", "Your Company Name" VALUE "FileDescription", "Your Application Description" VALUE "FileVersion", VER_FILE_VERSION_STR "\0" VALUE "InternalName", "Internal Name" VALUE "LegalCopyright", "CopyRight stuff - Copyright (C) 2015" VALUE "OriginalFilename", "yourapp.exe" VALUE "ProductName", "Your Application" VALUE "ProductVersion", VER_PRODUCT_VERSION_STR "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x407, 1200 END END 
  • Then add the version.h file to your project, which defines everything, configure as follows:

     #include "svn_version.h" #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) #define VERSION_MAJOR 1 #define VERSION_MINOR 0 #define VERSION_REVISION SVN_REVISION #define VERSION_BUILD 0 #if SVN_LOCAL_MODIFICATIONS #define VERSION_MODIFIER "M" #else #define VERSION_MODIFIER #endif #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD #define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ #define VER_PRODUCT_VERSION VER_FILE_VERSION #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR 

after that you can follow the link above .

+1
source

I'm not sure VS2008 has this feature, but I think you can do it with the post-linker event, which fires a little script that does this task for you.

0
source

I use a pre-build script (written in JavaScript and executed using the cscript.exe engine), which determines the major / minor release, gets the SVN version number and generates a magic build number based on the current date. The script then creates the version.h file, which is used by the main application (and the main application resource file to create the VERSION resource).

0
source

All Articles