Passing in version number to Inno Setup compiler

会有一股神秘感。 提交于 2020-01-14 03:29:10

问题


I want my Inno Setup script to be build using the command line, and I want to pass in the product version number as a parameter. I am trying to implement it like so:

[setup]
VersionInfoVersion={param:version|0.0.0.0}

However the compiler informs me this is invalid for that directive. I have read this post on how to pass in custom parameters from the command line and assume I should just be able to pass in something like:

compil32 /cc "c:\isetup\samples\my script.iss" /version=1.0.0.0

I have also tried the suggestion from this post and tried doing the following:

#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion('#PathToMyBinary\MyBinary.dll')

VersionInfoVersion={#ApplicationVersion}

But it doesn't seem to return anything. Both approaches seem valid to me so I'm hoping someone can explain where I am going wrong.


回答1:


Assuming you define the version via a pre-processor variable like:

[Setup]
VersionInfoVersion={#ApplicationVersion}

To set the version on a command-line, you have to use the ISCC.exe command-line compiler and its /D switch:

ISCC.exe Example1.iss /DApplicationVersion=1.2.3.4

To read the version from a binary, you are correctly using the GetFileVersion pre-processor function.

But your syntax to make-up the path is wrong.
A correct syntax is PathToMyBinary + '\MyBinary.dll', like:

#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion(PathToMyBinary + '\MyBinary.dll')

See Inno Setup Preprocessor: Expression Syntax.




回答2:


After looking at many different options I found that this worked for me.

This is the command line to compile the setup file

"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "MySetup.iss" /DVersion=1.2.3.4

In the setup file I added these lines, the first lines are to enable you to still run the script in the editor and ensure you would not get the error: Undeclared identifier: "Version"

#ifndef Version
  #define Version = '0.0.0.0';
#endif

[Setup]
VersionInfoVersion={#Version}


来源:https://stackoverflow.com/questions/36449026/passing-in-version-number-to-inno-setup-compiler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!