如何在 Inno Setup 的 AppVersion 值中只包含三部分文件版本(没有第四个修订号)
How to include only three-part file version (without fourth revision number) to the AppVersion value in Inno Setup
我已经使用 Inno Setup 6.0 为 Windows 桌面 WPF/C# 应用程序创建了设置,它工作正常。只是一个小装饰问题 - 我想使用“语义版本”。 Windows中的版本号有四个组成部分,major.minor.build.revision
但我想呈现major.minor.patch
。第四个组件将由 CI 使用,与用户无关。在当前脚本中,我有这个:
#define AppVersion GetFileVersion("..\app\bin\Release\app.exe")
... which later gets used as:
[Setup]
AppVersion=AppVersion
OutputBaseFilename=app.{#AppVersion}.x64
结果是由Inno Setup创建的app.1.0.1.781.x64.exe
,所以我正在寻找一种方法来切断最后一个版本组件- .781
。到目前为止,我还没有想出如何为此目的调用脚本函数。我可以在 [Code]
部分添加函数,但它将在 [Setup]
部分之后定义,显然不能在 [Setup]
部分调用?
是否可以在 Pascal 脚本中修改 AppVersion
和 OutputBaseFilename
的值,例如在 InitializeSetup()
中?
您可以使用GetVersionComponents
preprocessor function(Inno Setup 6.1 之前的ParseVersion
):
#define AppVerText() \
GetVersionComponents('..\app\bin\Release\app.exe', \
Local[0], Local[1], Local[2], Local[3]), \
Str(Local[0]) + "." + Str(Local[1]) + "." + Str(Local[2])
然后您可以在 [Setup]
部分中使用它:
AppVersion={#AppVerText}
您也可以将其用于 OutputBaseFilename
:
OutputBaseFilename=app.{#AppVerText}.x64
我已经使用 Inno Setup 6.0 为 Windows 桌面 WPF/C# 应用程序创建了设置,它工作正常。只是一个小装饰问题 - 我想使用“语义版本”。 Windows中的版本号有四个组成部分,major.minor.build.revision
但我想呈现major.minor.patch
。第四个组件将由 CI 使用,与用户无关。在当前脚本中,我有这个:
#define AppVersion GetFileVersion("..\app\bin\Release\app.exe")
... which later gets used as:
[Setup]
AppVersion=AppVersion
OutputBaseFilename=app.{#AppVersion}.x64
结果是由Inno Setup创建的app.1.0.1.781.x64.exe
,所以我正在寻找一种方法来切断最后一个版本组件- .781
。到目前为止,我还没有想出如何为此目的调用脚本函数。我可以在 [Code]
部分添加函数,但它将在 [Setup]
部分之后定义,显然不能在 [Setup]
部分调用?
是否可以在 Pascal 脚本中修改 AppVersion
和 OutputBaseFilename
的值,例如在 InitializeSetup()
中?
您可以使用GetVersionComponents
preprocessor function(Inno Setup 6.1 之前的ParseVersion
):
#define AppVerText() \
GetVersionComponents('..\app\bin\Release\app.exe', \
Local[0], Local[1], Local[2], Local[3]), \
Str(Local[0]) + "." + Str(Local[1]) + "." + Str(Local[2])
然后您可以在 [Setup]
部分中使用它:
AppVersion={#AppVerText}
您也可以将其用于 OutputBaseFilename
:
OutputBaseFilename=app.{#AppVerText}.x64