Conditional signing with Inno Setup - inno-setup

I'm using Inno Setup 6.0.3 and would like to control whether to sign the (un)installer via command-line. At the moment, my Setup.iss looks like this:
SignedUninstaller=true
SignTool=...
I would like to disable signing via a parameter/environment variable/whatever.
How can I do this?
The reason for this is that I'd like to disable signing on our developer workstations, whereas on our CI server the (un)installer should be signed.

InnoSetup compiler fully supports command line custom parameters, as exaplined in its Guide.
So you can define your own custom parameter within your Setup.iss file:
; CASE 1) "iscc.exe Setup.iss /DSIGN_UNINSTALLER=1" -> SIGN UNINSTALLER
; CASE 2) "iscc.exe Setup.iss -> SIGN UNINSTALLER
; CASE 3) "iscc.exe Setup.iss /DSIGN_UNINSTALLER=0" -> DOES NOT SIGN UNINSTALLER
; Enable by default (case 2)
#ifndef SIGN_UNINSTALLER
#define SIGN_UNINSTALLER "1"
#endif
...
#if SIGN_UNINSTALLER == "1"
SignedUninstaller=true
SignTool=...
#endif

Related

Configuring Visual & Installer in VS 2022 for x64

My config screen:
Why is it that I can't select x64 in the list? In the Alarm Clock row there is Add / Edit in the drop-down list. But not for AlarmClockSetup.
I am posting step by step tutorial because Configuration in Visual Studio works differently than in Inno Setup:
Lets assume user wants to build 2 installers: for 32 and 64 bit OS (two separate setup.exe-s).
Define 2 Visual Studio Configuration(s) for this using standard Visual Studio Configuration manager dialog, choose any names for them you wish, I chose: "setup32" and "setup64", the result will look like this:
For EACH configuration define some symbol (called conf in this example) in Project Properties like this: conf=$(Configuration)
It is important to have this symbol set for EACH configuration
And now double check whether you have defined this symbol for EACH configuration
If symbol is not defined for some Configuration you receive "Error on line XXX: Undeclared identifier: conf."
Inno script to test the configuration:
[Setup]
AppName=InnoSetupProject1
AppVersion=1.0
DefaultDirName={pf}\InnoSetupProject1
DefaultGroupName=InnoSetupProject1
UninstallDisplayIcon={app}\InnoSetupProject1.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Output
OutputBaseFilename=InnoSetupProject1
PrivilegesRequired=lowest
[Files]
Source: "Script.iss"; DestDir: "{app}"
[Icons]
Name: "{group}\InnoSetupProject1"; Filename: "{app}\InnoSetupProject1.exe"
[Code]
// Place your code here...
procedure InitializeWIzard();
begin
MsgBox(ExpandConstant('Configuration: {#conf}'), mbinformation,mb_ok);
#if conf == "setup32"
MsgBox('This is setup32', mbinformation,mb_ok);
#endif
#if conf == "setup64"
MsgBox('This is setup64', mbinformation,mb_ok);
#endif
end;
How it works:
When you choose "setup32" in Configuration dropdown, the $(Configuration) MSBuild variable is initialized and set to "setup32".
This $(Configuration) is mapped to Symbol conf (defined in Project Properties) that can be used anywhere in the script.
Use it for conditioning the setup behaviour using pre-processor #if, for Pascal code or anywhere as {#conf}.
So when the configuration is set to setup32 and you build the script, the Inno pre-processor excludes the inappropriate parts from the script and only the correct message box is shown.
Use the #if for include/exclude files in your script, for [Setup] section directives, for defining the Output directory or anything, choose the Configuration and rebuild the setup.

How to include only three-part file version (without fourth revision number) to the AppVersion value in Inno Setup

I have created setup for Windows desktop WPF/C# application using Inno Setup 6.0 and it works fine. Just a small cosmetic issue - I would like to use a "semantic version". The version number in Windows has four components, major.minor.build.revision but I want to present major.minor.patch. The fourth component will be used by CI and has no relevance for user. In the current script, I have this:
#define AppVersion GetFileVersion("..\app\bin\Release\app.exe")
... which later gets used as:
[Setup]
AppVersion=AppVersion
OutputBaseFilename=app.{#AppVersion}.x64
The result is app.1.0.1.781.x64.exe created by Inno Setup, so I'm looking for a way to cut off the last version component - .781. So far I haven't figured out how to invoke a script function for that purpose. I could add function in [Code] section but it will be defined after [Setup] section and apparently cannot be called in [Setup] section?
Is it possible to modify the values of AppVersion and OutputBaseFilename in Pascal script, for instance in InitializeSetup()?
You can use GetVersionComponents preprocessor function (ParseVersion before Inno Setup 6.1):
#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])
Then you can use this in your [Setup] section:
AppVersion={#AppVerText}
You can use this for OutputBaseFilename too:
OutputBaseFilename=app.{#AppVerText}.x64

How can I rewrite predefined messages for the WelcomePage in different languages in Inno Setup?

I have 3 languages and I need to change the AppName according to the language I've chosen.
I wrote this:
[Setup]
AppName={code:GetMyAppName}
[Code]
function GetMyAppName(param : String) : String;
begin
case ActiveLanguage of
'en': Result := 'AB Office Client';
'ru': Result := 'Клиент АБ Офис';
'ua': Result := 'Клієнт АБ Офіс';
end;
end;
And here I have my language-dependent [Messages] section:
[Messages]
en.WelcomeLabel1=Welcome to [APPNAME] Setup program. This program will install [APPNAME] on your computer.
ru.WelcomeLabel1=Вас приветствует программа установки [APPNAME] Эта программа установит [APPNAME] на Ваш компьютер.
ua.WelcomeLabel1=Вас вітає програма встановлення [APPNAME]. Ця програма встановить [APPNAME] на Ваш комп'ютер.
My question is: how can I transfer the result of the function GetMyAppName to the [APPNAME]? I could have done that by inserting a previously defined constant like {#AppName}, but I cannot use functions from the [Code] section with preprocessor's directives.
The same question is when I use [CustomeMessages] instead. Like this:
[Setup]
AppName={cm:AppName}
[CustomMessages]
en.AppName=AB Office Client
ru.AppName=Клиент АБ Офис
ua.AppName=Клієнт АБ Офіс
Also, I know that there are some arguments %1 and %2 in [Messages] section, but i have no idea how to use them. For me %1 and %2 argument just won't transfer to the AppName and AppVersion accordingly. They just stay as %1 and %2.
And finally, changing the .isl file manually is not an option for me.
Would really appreciate your help. Have a nice day.
The defaults are:
WelcomeLabel1=Welcome to the [name] Setup Wizard
WelcomeLabel2=This will install [name/ver] on your computer.%n%nIt is recommended that you close all other applications before continuing.
So just follow that – Use [name] and [name/ver] placeholders in your translations.
If you need other customization, see Can I use .isl files for the messages with preprocessor directives in Inno Setup? or Full preprocessor support in Inno Setup language files (isl).

Add Version to SetupWindowTitle of Inno Setup

The default Title of a Inno Setup Form is
Setup - %1
where %1 will be replaced by AppName from [Setup]-Section. I want to add the Version like this
Setup - MyProgramm 2.07.5
I've already managed to change the title by adding the [Messages]-Section and define the SetupWindowTitle. But this is fixed and i can't add the version string.
[Messages]
SetupWindowTitle=Setup - {AppName} {AppVersion}
This will result in
OK, I've found my mistake. The right syntax is
[Messages]
SetupWindowTitle=Setup - {#MyAppName} {#MyAppVersion}
And define some parameters at the beginning
#define MyAppName "MyProgram"
#define MyAppVersion GetStringFileInfo("package\MyProgram.exe", "FILEVERSION")
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
Set the AppVersion directive:
[Setup]
AppVersion=2.07.5
The value gets automatically into the SetupWindowTitle (indirectly via the default value of AppVerName directive).
You need Inno Setup 5.6 or newer.
You can also read the version from the executable:
[Setup]
AppVersion={#GetFileVersion(AddBackslash(SourcePath) + "MyProg.exe")}
See:
Using GetStringFileInfo in Setup section of Inno Setup
How do I automatically set the version of my Inno Setup installer according to my application version?

Inno Setup directive "VersionInfoVersion" is invalid

In my *.iss installer script I'm passing application version to the VersionInfoVersion param
VersionInfoVersion = {#ver}
where {#ver} is 0.4.0.201801182
According to Inno Setup documentation format is correct. However, I'm getting the following error:
Value of [Setup] section directive "VersionInfoVersion" is invalid.
Compile aborted.
The problem is the last section of your version. It appears that each section only supports up to 65,535. For example:
#define ver "0.4.0.65535" ;this works
#define ver "0.4.0.65536" ;this fails

Resources