Search code examples
.netinstallation64-bitwindows-installercustom-action

32 and 64 bit assemblies in one windows installer


I have an application written in C# which depends on sqlite managed provider. The sqlite provider is platform dependent (there are two dlls for 32 and 64 bit applications with the same name). The application loads the desired one at runtime based on OS.

The problem is that while creating an installer I cannot add 64 bit mode dll to the setup project as I am getting the following error: File '' targeting '' is not compatible with the project's target platform ''.

I would use other installer but I have a custom action which must be invoked during the setup.

So I wanted to know if there is an installer which will let me add 32 and 64 bit dll to it and execute custom action written in C#.

One possible solution is to have two installers but I would like to avoid it if possible.

Any suggestions?


Solution

  • The Inno Setup Installer support the feature wich you request, this installer is very flexible and reliable, exist many samples of scripts in the web to make a conditional installation depending of the architecture of the final client.

    Check this script located in C:\Program Files\Inno Setup 5\Examples\64BitThreeArch.iss

     -- 64BitThreeArch.iss --
    ; Demonstrates how to install a program built for three different
    ; architectures (x86, x64, Itanium) using a single installer.
    
    ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!
    
    [Setup]
    AppName=My Program
    AppVerName=My Program version 1.5
    DefaultDirName={pf}\My Program
    DefaultGroupName=My Program
    UninstallDisplayIcon={app}\MyProg.exe
    Compression=lzma2
    SolidCompression=yes
    OutputDir=userdocs:Inno Setup Examples Output
    ; "ArchitecturesInstallIn64BitMode=x64 ia64" requests that the install
    ; be done in "64-bit mode" on x64 & Itanium, meaning it should use the
    ; native 64-bit Program Files directory and the 64-bit view of the
    ; registry. On all other architectures it will install in "32-bit mode".
    ArchitecturesInstallIn64BitMode=x64 ia64
    
    [Files]
    ; Install MyProg-x64.exe if running on x64, MyProg-IA64.exe if
    ; running on Itanium, MyProg.exe otherwise.
    Source: "MyProg-x64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: IsX64
    Source: "MyProg-IA64.exe"; DestDir: "{app}"; DestName: "MyProg.exe"; Check: IsIA64
    Source: "MyProg.exe"; DestDir: "{app}"; Check: IsOtherArch
    Source: "MyProg.chm"; DestDir: "{app}"
    Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
    
    [Icons]
    Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
    
    [Code]
    function IsX64: Boolean;
    begin
      Result := Is64BitInstallMode and (ProcessorArchitecture = paX64);
    end;
    
    function IsIA64: Boolean;
    begin
      Result := Is64BitInstallMode and (ProcessorArchitecture = paIA64);
    end;
    
    function IsOtherArch: Boolean;
    begin
      Result := not IsX64 and not IsIA64;
    end;