aatwo
aatwo

Reputation: 1008

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...

Upvotes: 1

Views: 131

Answers (1)

Andrew Truckle
Andrew Truckle

Reputation: 19157

Based on this answer (Inno Setup IDE and ISCC/ISPP passing define) you could do this:

  1. Pass the value via command line parameter:

    /DargDEV="DEV"
    
  2. 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.

Upvotes: 2

Related Questions