开发者

32 and 64 bit assemblies in one windows installer

开发者 https://www.devze.com 2022-12-28 07:23 出处:网络
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 appl

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 开发者_StackOverflow'' 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?


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;


With Windows Installer, no. You'll need two setups.

However NSIS is quite capable of handling both platforms in a single setup with runtime detection. It really depends if you're targeting Enterprise users or not, Enterprise customers will require Windows Installer (MSI) packages while your average internet user doesn't care :)


I like the idea of Inno setup, I would probably give it a try, but consider the following:

Microsoft MSI best practice is to have 2 seperate setup, one for 32 and one for 64, and many 3rd party IDE like Installshield endorse those best practices. IMO there are probably reasons for this, otherwise they would have added this feature to have an edge over competitors.

To build 2 setups from a single setup project, You'd have have both installers built from the same setup project, using releases flags, you basically create one feature containing your 32bit assemblies, another one containing the 64bit ones, assign a release flag to each of them, and build each release separately,

So at build time, you build the 32bit release, it's packaged, while the 64bit is ignored, then you do the same for 64bit. You can pass those flags through command line arguments if needed.

This way you have no duplicate setup code to maintain.


Windows Installer works fine in this scenario, e.g. have two Components each with one of the sqlite files and conditionally install one or the other based on the VersionNT64 property, which is only set when the installation runs on a 64-bit platform.

0

精彩评论

暂无评论...
验证码 换一张
取 消