'How to control addition of file in Inno Setup 6 script using the presence of a substring in a defined string
I have two executables which do the same thing, but one is built to target a DEV environment, and the other a PROD environment.
my-app-dev.exe
my-app-prod.exe
A VERSION parameter is always passed into the Inno build script which contains the build version in one of the following two formats:
"1.0.0"
"1.0.0-DEV"
In the [Files] section, how can I include the my-app-dev.exe if the current value of VERSION contains the DEV suffix, but include the my-app-prod.exe if not?
I figured a Check parameter would be the way to resolve this, but I can't even get the simplest case to work.
For example, the following adds the file to the build despite the Check function clearly returning False.
[Files]
Source: "my-app-dev.exe"; DestDir: {app}; Check: ShouldIncludeDev
function ShouldIncludeDev: Boolean;
begin
Result := False;
end;
Perhaps I must be missing something fundamental here...
Solution 1:[1]
Based on this answer (Inno Setup IDE and ISCC/ISPP passing define) you could do this:
Pass the value via command line parameter:
/DargDEV="DEV"In your
[Files]section you can then do this:#ifdef argDEV Source: "my-app-dev.exe"; DestDir: {app}; #else Source: "my-app-prod.exe"; DestDir: {app}; #endif
Notes
It uses the #ifdef pre-processor directive.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Prikryl |
