Scott Tan
Scott Tan

Reputation: 101

Passing space only property from Visual Studio project build to Inno Setup compiler

In my Inno Setup script, I have a variable called BuildString defined like below.

#ifndef BuildString
  #define BuildString " - No Config"

But in my VS project post-build event, I will have some specific value passed in like "Beta"/"Admin" or even just an empty string like " ".

In my [Icons] section, I have an if-statement to conditionally create shortcuts for the software and codes are as follows.

#if SameText(BuildString, " - some text")
Name: "{group}\---"; Filename: "{app}\---.exe"; \
    IconFilename: "{app}\---.exe"; Parameters:""
Name: "{commondesktop}\---"; Filename: "{app}\---.exe"; \
    IconFilename: "{app}\---.exe"; Parameters:""
#endif

I have tried with the "Beta" keyword and I can build the installer without issues via VS.

But if I passed in " " (a space, it's legitimate in my use-case). I then have this error shown in the output window.

Error on line 110 in Installer.iss: [ISPP] Actual parameter S1 is not of the declared type.

Line 110 is referring to the code #if SameText(BuildString, " - some text")

I have tried to compile the same script using Inno Setup compiler and it was no issue. So I wonder if there is any difference between the way VS/Inno Setup compiler compiles the codes.


This is the build config I am building.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Editor - Master - Obfuscated|x86' ">
  <UpgradeCode>00000000000000000000</UpgradeCode>
  <BuildString>
  </BuildString>
  <CmdLineArgs>
  </CmdLineArgs>
  <OutputPath>bin\$(Configuration)\</OutputPath>
  <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<Prefer32Bit>false</Prefer32Bit>

And I call the Inno script using the command below in PostBuildEvent of my Installer project.

<PostBuildEvent>"$(ProjectDir)InnoSetUp\ISCC.exe" "$(ProjectDir)Installer.iss" "/DProjectDir=$(ProjectDir).." "/DBuildConfig=$(Configuration)" "/DBuildString=$(BuildString)" "/DCmdLineArgs=$(CmdLineArgs)" 
Powershell.exe -executionpolicy remotesigned -File "$(ProjectDir)$(OutDir)..\..\Pcmtec.Installer.ps1" "$(BuildString)"</PostBuildEvent>

Upvotes: 2

Views: 148

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202534

I have tried adding this to my VS project:

<BuildString> </BuildString>
<PostBuildEvent>cmd /c echo "$(BuildString)"</PostBuildEvent>

Then I get "" (no space between) in VS Output pane.

So apparently, the space is not preserved by Visual Studio (what is imo actually a normal behavior in XML files) => Nothing to do with Inno Setup.

All you can do on Inno Setup side is to change your logic, so that it does not need space-only parameter. Or you can use e.g. _ instead of space and replace it with space in Inno Setup.

Upvotes: 1

Related Questions