Summary: Having the version details defined in the separately maintained version.inc
via preprocessor macros... How to include the macro values into the resource version definition block?
My version.inc
file is stored in UTF-8 (i.e. pure ASCII in the case). Its full content is the following (the APS_
prefix here is related to the real name of the application, not to the .aps
file generated by the resource compiler):
#define APS_MAJORNUMBER 4
#define APS_MINORNUMBER 5
#define APS_BUILDNUMBER 0
#define APS_MODIFICATIONNUMBER 0
#define APS_BUILDEXT "wx"
#define APS_DATEYEAR 2012
#define APS_DATEMONTH 10
#define APS_DATEDAY 4
The Visual Studio 2012 C++ seems to be more picky about the resource script file (app.rc
) than the Visual Studio 2010 was. The first thing I have noticed is that when editing it manually, I have to keep the UTF-16 encoding. Can you confirm that? Is there any documentation on that?
Say the version block in the app.rc
looks like this:
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040504b0"
BEGIN
VALUE "CompanyName", "TODO: <Company name>"
VALUE "FileDescription", "TODO: <File description>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "app.exe"
VALUE "LegalCopyright", "Copyright (C) 2012"
VALUE "OriginalFilename", "app.exe"
VALUE "ProductName", "TODO: <Product name>"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x405, 1200
END
END
In the earlier versions of Visual Studio (2005 and 2010), I was able to have the related version.rc2
like this:
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#include "version.inc"
#define STR(value) #value
#define STRINGIZE(value) STR(value)
#define APS_FULLVERSION_STR \
STRINGIZE(APS_MAJORNUMBER) "." \
STRINGIZE(APS_MINORNUMBER) "." \
STRINGIZE(APS_BUILDNUMBER) "." \
STRINGIZE(APS_MODIFICATIONNUMBER)
VS_VERSION_INFO VERSIONINFO
FILEVERSION APS_MAJORNUMBER,APS_MINORNUMBER,APS_BUILDNUMBER,APS_MODIFICATIONNUMBER
PRODUCTVERSION APS_MAJORNUMBER,APS_MINORNUMBER,APS_BUILDNUMBER,APS_MODIFICATIONNUMBER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x29L
#else
FILEFLAGS 0x28L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "A fairly useful tool named APS"
VALUE "CompanyName", "The company name"
VALUE "FileDescription", "app"
VALUE "FileVersion", APS_FULLVERSION_STR
VALUE "InternalName", "aps"
VALUE "LegalCopyright", "Copyright © 1993-" STRINGIZE(APS_DATEYEAR)
VALUE "OriginalFilename", "app.exe"
VALUE "PrivateBuild", ""
VALUE "ProductName", "APS of the version 4"
VALUE "ProductVersion", APS_FULLVERSION_STR
VALUE "SpecialBuild", APS_BUILDEXT
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
Then the version.rc2
was included into the app.rc
via editing the app.rc
manually. However, I cannot repeat the process with the Visual Studio 2012 project and resource file. I may be doing some mistake invisible to me. Should that approach work also in Visual Studio 2012?
Thanks for you time and experience,
Petr