安装文件名可以从可执行文件版本号中得出吗?
是否可以让 Inno Setup 读取主可执行文件的文件版本并将创建的安装程序的名称设置为“myapp_setup_1_0_3708_19805.exe”之类的名称?
Is it possible to get Inno Setup to read the file version of the main executable file and set the name of the created setup to something like "myapp_setup_1_0_3708_19805.exe"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你应该能够这样做:(
我最近没有尝试过这个,但它确实在 2007 年我以这种方式使用 InnoSetup 时起作用。如果 Inno 的语法从那时起发生了变化,它可能需要一些细微的改变。)
如果MyMainFile.exe 的版本是 1.2.3.4,那么应该调用完成的安装程序 setup_mytool_1_2_3_4.exe
AVF1、AVF2 等内容只是用下划线 (_) 替换版本号中的点 (.),以避免导致问题无法处理文件名中的大量点的事情。
You should be able to do it like this:
(I haven't tried this recently but it certainly worked back in 2007 when I was using InnoSetup in this way. It might need some slight changes if Inno's syntax has changed since then.)
If MyMainFile.exe was version 1.2.3.4 then that should call the finished installer setup_mytool_1_2_3_4.exe
The AVF1, AVF2, etc. stuff is just there to replace the dots (.) in the version number with underscores (_) to avoid causing problems with things that can't cope with lots of dots in a filename.
GetFileVersion()
(在其他答案中描述)返回“Major.Minor.Rev.Build”形式的字符串。如果您想要访问各个元素以便自己格式化字符串(例如,如果您只需要“Major.Minor”或“Major.Minor.Rev”),则可以使用 jrsoftware.innosetup 邮件列表:GetFileVersion()
(described in other answers) returns a string of the form "Major.Minor.Rev.Build." If you want access to the individual elements so that you can format the string yourself (say, if you only want "Major.Minor" or "Major.Minor.Rev"), you can use the following approach from the jrsoftware.innosetup mailing list:一种更简洁的方法是使用
StringChange
函数,该函数允许用其他内容替换点:此外,如果您不想显示所有四个版本号(例如,您希望它说
1.0.1
而不是1.0.1.0
),您可以将AppVersion
行替换为以下内容:A much cleaner way of doing this involves using the
StringChange
function, which allows replacing the dots with something else:Also, if you don't want to show all four version numbers (e.g. you want it to say
1.0.1
instead of1.0.1.0
), you can replace theAppVersion
line with the following: