views:

1857

answers:

4

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:

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

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

Game-Release-Build-1002.exe

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.

+3  A: 

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.

flipdoubt
A: 

I'm not sure VS2008 has that feature but I think you can do it with a post-linker event that runs a little script that make the task for you.

jab
A: 

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

Rob
Sounds great. Care to post it then?
Brock Woolf
A: 

My own approach, including binary file stamping:

http://indiocolifax86.wordpress.com/2010/05/22/a-scheme-for-automatic-build-numbers-in-cc-projects/

Hernán