windows .exe 和 .dll 文件的批量设置版本号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4587841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:53:53  来源:igfitidea点击:

Batch set version number for .exe and .dll files

windowsbuild-automationversioning

提问by theycallmemorty

Is there a tool that would allow me to to do something like this: thetool.exe '1.0.0.1' mydll.dll myexe.exe?

有没有一种工具可以让我做这样的事情:thetool.exe '1.0.0.1' mydll.dll myexe.exe

Basically I would like to automate the process of making my builds and then have a tool automatically set the version numbers for me.

基本上我想自动化构建我的过程,然后有一个工具自动为我设置版本号。

回答by xt1

You can use the answers to this question: How do I set the version information for an existing .exe, .dll?

您可以使用以下问题的答案:如何设置现有 .exe、.dll 的版本信息?

verpatch /va foodll.dll %VERSION% "%FILEDESCR%" "%COMPINFO%" "%PRODINFO%" "%BUILDINFO%"

verpatch /va foodll.dll %VERSION% "%FILEDESCR%" "%COMPINFO%" "%PRODINFO%" "%BUILDINFO%"

Available at http://www.codeproject.com/KB/install/VerPatch.aspx?msg=3207401

可在http://www.codeproject.com/KB/install/VerPatch.aspx?msg=3207401 获得

With full sources...

有完整的来源...

回答by Ken White

The version number is stored in a VERSIONINFOresource (a compiled binary resource) inside the executable. Most IDEs or compilers come with a resource compiler as well (Delphi and C++ Builder include brcc32.exe, for instance).

版本号存储在可执行文件内的VERSIONINFO资源(已编译的二进制资源)中。大多数 IDE 或编译器也带有资源编译器(例如,Delphi 和 C++ Builder 包括 brcc32.exe)。

Unless your IDE allows you to auto-increment a version or build number as part of the build process, you'll end up needing to create the text .RC file for a VERSIONINFO resource and using your resource compiler to compile it and add it to your final executable or dll.

除非您的 IDE 允许您在构建过程中自动增加版本或构建号,否则您最终需要为 VERSIONINFO 资源创建文本 .RC 文件并使用资源编译器来编译它并将其添加到您最终的可执行文件或 dll。