在构建时更改版本号 [英] change version number at build time
问题描述
作为构建脚本的一部分,我需要将我的 delphi 项目的版本设置为与另一个项目(不是 delphi)相同.有没有办法在不通过 IDE 的情况下控制版本号,例如编译器的命令行参数或类似的东西?谢谢
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
推荐答案
包括一行
{$R 'version.res'}
在您的项目中.并使用您的版本信息创建一个 version.rc 文件.您必须使用 brcc32 在较旧的 Delphi 版本中自己构建资源.在较新的 Delphi 版本中,您可以使用
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'}
让 IDE 为您自动构建它.
to have the IDE build it automatically for you.
最简单的 version.rc 如下所示:
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 "
VALUE "FileVersion", "9999.9999.99.18048 "
VALUE "LegalCopyright", "Copyright "
VALUE "ProductName", "Product Name "
VALUE "ProductVersion", "9999.9999.99.18048 "
VALUE "Homepage", "http://www.mydomain.com "
}
}
}
有关详细信息,请参阅 MSDN 上的 VERSIONINFO 结构.
For more information, please refer to MSDN on the VERSIONINFO structure.
这篇关于在构建时更改版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!