I need to set the version of my delphi project to be the same as another project (not delphi) as part of a build script. Is there a way to control the version number without going thru the IDE, for example command line param of the compiler or something like that? Thanks
Include a line like
{$R 'version.res'}
in your project. And create a version.rc file with your version information. You will have to build the resource yourself in older Delphi versions using brcc32. In newer Delphi versions you can use
{$R 'version.res' 'version.rc'}
to have the IDE build it automatically for you.
The simplest version.rc would look something like:
1 VERSIONINFO
FILEVERSION 9999, 9999, 99, 18048
PRODUCTVERSION 9999, 9999, 99, 18048
FILEOS 0x00000004L // comment: VOS_WINDOWS32
FILETYPE VFT_APP
{
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 0x4E4 // comment: 0x4E4 = 1252
}
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", "Company Name\0"
VALUE "FileVersion", "9999.9999.99.18048\0"
VALUE "LegalCopyright", "Copyright \0"
VALUE "ProductName", "Product Name\0"
VALUE "ProductVersion", "9999.9999.99.18048\0"
VALUE "Homepage", "http://www.mydomain.com\0"
}
}
}
For more information, please refer to MSDN on the VERSIONINFO structure.
Marjan gives an excellent answer above, but my answer takes the answer a little further. Consider this RC file:
VS_VERSION_INFO VERSIONINFO
#include "..\Ver_Num_Application.txt"
#define APPLICATION_NAME "My amazing project\0"
#define VER_NUM_ARTWORKS 4
#include "..\Libraries\Paslib32\Ver_Num_Library.txt"
#define COMPANY_NAME "My company\0"
FILEVERSION VER_NUM_ARTWORKS, VER_NUM_LIBRARY, VER_NUM_APPLICATION, 1000
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
#else
FILEFLAGS 0x8L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", APPLICATION_NAME
VALUE "LegalCopyright", "Copyright (C) "COMPANY_NAME
VALUE "ProductName", APPLICATION_NAME
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
The benefit in using the several #INCLUDE statements is that you can leave the RC file alone and then simply modify (or even auto-generate) the *.txt include files which look like:
Ver_Num_Application.txt:
#define VER_NUM_APPLICATION 6
Ver_Num_Library.txt:
#define VER_NUM_LIBRARY 156
Note that now you have to delete the *.res files before running your build to force the linker to regenerate them from (possibly changed) version numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With