设置文件名可以从可执行文件的版本号中获取吗? [英] Can the setup filename be derived from the executable file version number?
问题描述
是否可以使Inno Setup读取主可执行文件的文件版本并将创建的安装程序的名称设置为"myapp_setup_1_0_3708_19805.exe"之类的内容?
您应该可以这样做:
(我最近还没有尝试过,但是肯定可以回溯到2007年,当时我以这种方式使用InnoSetup.如果从那时起Inno的语法发生了变化,它可能需要稍作更改.)
#define MainBinaryName "MyMainFile.exe"
#define SetupBaseName "setup_mytool_"
#define AppVersion GetFileVersion(AddBackslash(SourcePath) + MainBinaryName)
#define AVF1 Copy(AppVersion, 1, Pos(".", AppVersion) - 1) + "_" + Copy(AppVersion, Pos(".", AppVersion) + 1)
#define AVF2 Copy(AVF1, 1, Pos(".", AVF1 ) - 1) + "_" + Copy(AVF1 , Pos(".", AVF1 ) + 1)
#define AppVersionFile Copy(AVF2, 1, Pos(".", AVF2 ) - 1) + "_" + Copy(AVF2 , Pos(".", AVF2 ) + 1)
[Setup]
OutputBaseFilename={#SetupBaseName + AppVersionFile}
如果MyMainFile.exe的版本为1.2.3.4,则应调用完成的安装程序setup_mytool_1_2_3_4.exe
仅使用AVF1,AVF2等内容将版本号中的点(.)替换为下划线(_),以避免引起无法处理文件名中许多点的问题. /p>
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"?
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.)
#define MainBinaryName "MyMainFile.exe"
#define SetupBaseName "setup_mytool_"
#define AppVersion GetFileVersion(AddBackslash(SourcePath) + MainBinaryName)
#define AVF1 Copy(AppVersion, 1, Pos(".", AppVersion) - 1) + "_" + Copy(AppVersion, Pos(".", AppVersion) + 1)
#define AVF2 Copy(AVF1, 1, Pos(".", AVF1 ) - 1) + "_" + Copy(AVF1 , Pos(".", AVF1 ) + 1)
#define AppVersionFile Copy(AVF2, 1, Pos(".", AVF2 ) - 1) + "_" + Copy(AVF2 , Pos(".", AVF2 ) + 1)
[Setup]
OutputBaseFilename={#SetupBaseName + AppVersionFile}
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.
这篇关于设置文件名可以从可执行文件的版本号中获取吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!