简体   繁体   English

一个Windows安装程序中的32位和64位程序集

[英]32 and 64 bit assemblies in one windows installer

I have an application written in C# which depends on sqlite managed provider. 我有一个用C#编写的应用程序,它依赖于sqlite托管提供程序。 The sqlite provider is platform dependent (there are two dlls for 32 and 64 bit applications with the same name). sqlite提供程序是依赖于平台的(有两个dll用于32位和64位具有相同名称的应用程序)。 The application loads the desired one at runtime based on OS. 应用程序在运行时基于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 ''. 问题是,在创建安装程序时,我无法将64位模式dll添加到安装项目中,因为我收到以下错误: 文件“'目标''与项目的目标平台不兼容''。

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#. 所以我想知道是否有一个安装程序可以让我添加32位和64位dll并执行用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. Inno Setup Installer支持您请求的功能,此安装程序非常灵活可靠,在Web中存在许多脚本示例,以根据最终客户端的体系结构进行条件安装。

Check this script located in C:\\Program Files\\Inno Setup 5\\Examples\\64BitThreeArch.iss 检查位于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;

Windows Installer在这种情况下工作正常,例如,有两个组件,每个组件都有一个sqlite文件,并根据VersionNT64属性有条件地安装一个或另一个,该属性仅在安装在64位平台上运行时设置。

With Windows Installer, no. 使用Windows Installer,没有。 You'll need two setups. 你需要两个设置。

However NSIS is quite capable of handling both platforms in a single setup with runtime detection. 但是, NSIS能够在运行时检测的单个设置中处理这两个平台。 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 :) 这实际上取决于您是否针对企业用户,企业客户将需要Windows Installer(MSI)包,而您的普通互联网用户并不关心:)

I like the idea of Inno setup, I would probably give it a try, but consider the following: 我喜欢Inno设置的想法,我可能会尝试一下,但请考虑以下内容:

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. Microsoft MSI的最佳实践是两个单独的设置,一个用于32个,一个用于64个,而许多第三方IDE(如Installshield)支持这些最佳实践。 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, 要从单个安装项目构建2个安装程序,您必须使用版本标记构建两个安装程序,使用版本标记,基本上创建一个包含32位程序集的功能,另一个包含64位程序集,添加一个释放标记到他们每个人,并分别建立每个版本,

So at build time, you build the 32bit release, it's packaged, while the 64bit is ignored, then you do the same for 64bit. 所以在构建时,你构建32位版本,它是打包的,而64位被忽略,那么你对64位做同样的事情。 You can pass those flags through command line arguments if needed. 如果需要,您可以通过命令行参数传递这些标志。

This way you have no duplicate setup code to maintain. 这样您就无需维护重复的设置代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM