How to increment version information after each build in Visual C++
Posted by Just little ol' me at Thursday, April 03, 2008
I was trying to find how you can automatically increment the version number for my C++ application. Then I found this useful post on the MSDN site, so I am sharing it with you.
You can find all the needed information in the post, so I am just posting a summary for those of you who just want to get an idea of how to do it.
Basically, you need to create a Visual Studio macro and register it for the BuildFinish event. You then move the version information from resources in a separate file (to make sure the macro does not mess anything up) and tell the macro (using VB code) to edit the file containing the version number and increment it. What happens is that after each build, VS executes the macro, which modifies the text file (actually, a header file) incrementing the version number. This way, for each build you will have a new version number for the application.
Even if you do not need automatically incremented versions for each build, the MSDN tutorial is useful because it show C++ newbies (like myself) how to easily separate the version number from the rest of the resources and keep the version number in just one place.
The link to the site is: http://support.microsoft.com/kb/237870
Build it safe :)
PS: Another cool post shows how to update the version information at runtime. Thanx to CodeProject for this one: http://www.codeproject.com/KB/cpp/UpdateVersion.aspx
Labels: build , c++ , version number , Visual Studio