inno-setupvisual-studio-2022visual-and-installer

Configuring Visual & Installer in VS 2022 for x64


My config screen:

enter image description here

Why is it that I can't select x64 in the list? In the Alarm Clock row there is Add / Edit in the drop-down list. But not for AlarmClockSetup.


Solution

  • I am posting step by step tutorial because Configuration in Visual Studio works differently than in Inno Setup:

    Lets assume user wants to build 2 installers: for 32 and 64 bit OS (two separate setup.exe-s).

    Define 2 Visual Studio Configuration(s) for this using standard Visual Studio Configuration manager dialog, choose any names for them you wish, I chose: "setup32" and "setup64", the result will look like this:

    setup64 configuration

    Configuration Manager

    For EACH configuration define some symbol (called conf in this example) in Project Properties like this: conf=$(Configuration)

    It is important to have this symbol set for EACH configuration

    And now double check whether you have defined this symbol for EACH configuration

    Project Properties

    If symbol is not defined for some Configuration you receive "Error on line XXX: Undeclared identifier: conf."

    Inno script to test the configuration:

    [Setup]
    AppName=InnoSetupProject1
    AppVersion=1.0
    DefaultDirName={pf}\InnoSetupProject1
    DefaultGroupName=InnoSetupProject1
    UninstallDisplayIcon={app}\InnoSetupProject1.exe
    Compression=lzma2
    SolidCompression=yes
    OutputDir=userdocs:Output
    OutputBaseFilename=InnoSetupProject1
    PrivilegesRequired=lowest
    
    [Files]
    Source: "Script.iss"; DestDir: "{app}"
    
    [Icons]
    Name: "{group}\InnoSetupProject1"; Filename: "{app}\InnoSetupProject1.exe"
    
    [Code]
    
    // Place your code here...   
    
    procedure InitializeWIzard();
    begin
        MsgBox(ExpandConstant('Configuration: {#conf}'), mbinformation,mb_ok);
    
    #if conf == "setup32"
        MsgBox('This is setup32', mbinformation,mb_ok);
    #endif
    
    #if conf == "setup64"
        MsgBox('This is setup64', mbinformation,mb_ok);
    #endif
    end;
    

    How it works:

    When you choose "setup32" in Configuration dropdown, the $(Configuration) MSBuild variable is initialized and set to "setup32".

    This $(Configuration) is mapped to Symbol conf (defined in Project Properties) that can be used anywhere in the script.

    Use it for conditioning the setup behaviour using pre-processor #if, for Pascal code or anywhere as {#conf}.

    So when the configuration is set to setup32 and you build the script, the Inno pre-processor excludes the inappropriate parts from the script and only the correct message box is shown.

    Use the #if for include/exclude files in your script, for [Setup] section directives, for defining the Output directory or anything, choose the Configuration and rebuild the setup.

    IDE