2
votes

I have an setup script to generate the setup, this works fine. Now I created a PowerShell script, that takes 2 parameters, "program" - name of the program and "version", version of the program. The PowerShell script just copies the files somewhere based on the version.

In Inno Setup Studio I try to run the PowerShell script after the compile in the [PostCompile] section with following line:

[PostCompile]    
Name: "copysetups.cmd"; Parameters: "Program {#AppVers} "; Flags: cmdprompt redirectoutput

The batch file is called but the variable is not replaced with its value following output is shown in the messages window of Inno Script Studio:

powershell.exe .\copySetups.ps1 -program Program -version {#AppVer}

I also tried doing it via "code: like this:

[PostCompile]
Name: "copysetups.cmd"; Parameters: "Program ""{code:GetAppVersion}"""; Flags: cmdprompt redirectoutput

The function:

function GetAppVersion( Param: String ): String;
begin
  Result := '{#AppVer}';
end;

But this doesn't work either, output is again not with the value from the function.

powershell.exe .\copySetups.ps1 -program Program -version {code:GetAppVersion} 
1

1 Answers

3
votes

Inno Setup Studio does not support preprocessor in the [PostCompile] section. See also Inno Setup copy OutputBaseFileName in PostCompile section.

And there's no way {code:...} can work either, as constants (as well as any Pascal Script code) are evaluated on run time only.


Why don't you make the PowerShell script read the version from the compiled .exe?

[System.Diagnostics.FileVersionInfo]::GetVersionInfo("mysetup.exe").ProductVersion