Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically updating FILEVERSION in a MFC app w/SVN revision number

How do I go about programmatically updating the FILEVERSION string in an MFC app? I have a build process that I use to generate a header file which contains the SVN rev for a given release. I'm using SvnRev from http://www.compuphase.com/svnrev.htm to update a header file which I use to set the caption bar of my MFC app. Now I want to use this #define for my FILEVERION info.

What's the best way to proceed?

like image 243
swilc0x Avatar asked Sep 20 '08 18:09

swilc0x


2 Answers

An .rc file can #include header files just like .c files can. I have an auto-generated version.h file, which defines things like:

#define MY_PRODUCT_VERSION    "0.47"
#define MY_PRODUCT_VERSION_NUM 0,47,0,0

Then I just have my .rc file #include "version.h" and use those defines.

VS_VERSION_INFO VERSIONINFO
 FILEVERSION MY_PRODUCT_VERSION_NUM
 PRODUCTVERSION MY_PRODUCT_VERSION_NUM
...
 VALUE "FileVersion", MY_PRODUCT_VERSION "\0"
 VALUE "ProductVersion", MY_PRODUCT_VERSION "\0"
...

I haven't tried this technique with an MFC project. It might be necessary to move your VS_VERSION_INFO resource to your .rc2 file (which won't get edited by Visual Studio).

like image 88
cjm Avatar answered Oct 24 '22 04:10

cjm


Don't have enough points to comment yet, but whatever solution you choose keep in mind that FILEVERSION fields can only support a short integer. In our situation, our SVN revision was already above this and resulted in an invalid revision number in our FILEVERSION.

like image 3
Dan Avatar answered Oct 24 '22 03:10

Dan