7

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.

Community
  • 1
  • 1
JNH
  • 477
  • 1
  • 5
  • 15

3 Answers3

15

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

If you want to provide a default value for the version, so the script can compile even without defining the variable on the command line, use #ifndef at the top of the script:

#ifndef ApplicationVersion
#define ApplicationVersion "1.2.3.4"
#endif

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 2
    I'm now setting the version using the pre-processor function GetFileVersion and it is working now that I am using the correct syntax, thanks. – JNH Apr 06 '16 at 15:29
  • 1
    In the docs they show what exactly is happening with the parameter. Ex. `/D[=] Emulate #define public ` – Maksim Apr 07 '21 at 17:20
4

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}
KakNaam
  • 41
  • 1
0

In order to get my setup script (iss file) to work, I had to remove the #define ApplicationVersion line from my script. Once I did that, it recognized my /DApplicationVersion=8 input parameter.

"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "install.iss" /DApplicationVersion=8

David Ehnis
  • 122
  • 8