views:

264

answers:

4

I've got a solution with about 8 separate projects in it and every time I do a release build of the entire solution I need to make sure that the version string for the binary output of each project is the same. Is there an easy way to synchronize the VS_VERSION_INFO section of a project's resources file?

+1  A: 

We used FinalBuilder for our builds and let it go through the files (as text files) and update them with correct version info.

Ulf Lindback
+1  A: 

The simplest way to implement this would be with a prebuild step that calls a script of some sort (sed/awk, PowerShell, etc.) for all of your resource files and drops in the correct values in the appropriate places. If you use SVN, then SubWCRev from the TortoiseSVN distribution could be used for this piece as well, and could automatically use the revision number from your repository as the version string.

Harper Shelby
+4  A: 

I don't know that this is the way you would want to go, but .rc files allow includes, and you can use #define values in the version block

Define version numbers in a header file


#define VER_MAJOR 8
#define VER_MINOR 00
#define VER_BUILD_HI    00
#define VER_BUILD_LO 021
#define VER_FLAGS   VS_FF_PRERELEASE


// The Binary form of the version numbers
#define VER_FILE    VER_MAJOR, VER_MINOR, VER_BUILD_HI, VER_BUILD_LO
#define VER_PRODUCT VER_MAJOR, VER_MINOR, 0, 0

#define VER_STR(arg) #arg

// The String form of the version numbers
#define VER_FILE_STRING VALUE "FileVersion", "8.0\0"
#define VER_PRODUCT_STRING VALUE "ProductVersion", "8.0\0"

Use them in the VS_VERSION_INFO block


#include "bversion.h" //#define values in here

VS_VERSION_INFO VERSIONINFO
 FILEVERSION VER_FILE
 PRODUCTVERSION VER_PRODUCT
 FILEFLAGSMASK 0x2fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "\0"
            VALUE "CompanyName", "XXX\0"
            VALUE "FileDescription", "YYY\0"
            VER_FILE_STRING
            VALUE "InternalName", "ZZZ\0"
            VALUE "LegalCopyright", "© 2009 PDQ.\0"
            VALUE "LegalTrademarks", "AAA\0"
            VALUE "OriginalFilename", "BBB.EXE\0"
            VALUE "PrivateBuild", "\0"
            VALUE "ProductName", "CCC\0"
            VER_PRODUCT_STRING
            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

Reference the one header file in all of the projects and change it before each build.

crashmstr
A: 

You can write a bit of code using ResourceLib to do that or adopt a build process that does it for you.

dblock