pythoninstallationinno-setuppyinstallerfileversioninfo

Compiler error when using GetStringFileInfo in InnoSetup on application created with PyInstaller


I created version info file as described here - What does a "version file" look like? and do got EXE-file with all version information.

My issue is next, when I try to build setup file with InnoSetup, I'm getting an error:

Error on line 65 in d:\installation\Source\setup_script.iss: Missing closing quote on parameter "Name"

line 65:

[Icons]
Name: "{group}\{#VerInfoProductName}"; Filename: "{app}\{#ExeFileName}.exe"; WorkingDir: "{app}"

Definition of VerInfoProductName below

#define VerInfoProductName GetStringFileInfo(AddBackslash(SourcePath) + "..\..\dist\app\testapp.exe", "ProductName")

Details are attached in archive.


Solution

  • There's something in your application version info strings that confuses the Inno Setup pre-processor. Your code works with other applications.

    The pre-processor loads the ProductName in a way that resulting variable is actually longer than the value, the remaining space filled with some garbage that later confuses the compiler.

    You can workaround it by using {#SetupSetting('AppName')} instead of {#VerInfoProductName}. This of course assumes that AppName is set to {#VerInfoProductName}.

    Another way is to round-trip the string via an INI file:

    #expr WriteIni("C:\path\xxx.ini", "xxx", "xxx", VerInfoProductName)
    #define VerInfoProductName ReadIni("C:\path\xxx.ini", "xxx", "xxx")
    

    Actually in normal Windows resource files (.rc), one has to explicitly null-terminate the version info strings (note the \0):

    VALUE "ProductName", "TestProductName\0"
    

    The resulting null (\0) character is explicitly stored in the resulting binary. So in the end there are two null characters in the resulting binary (four 0 bytes in UTF-16 encoding). This is common WinAPI format when multiple values are allowed. The null character is values separator, the double-null terminates the sequence.

    Your TestApp.exe is missing that second null. I can see that in a hex dump. I'm pretty sure that this is the primary cause of your problem.