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

时间:2010-04-28 20:33:00

标签: .net installer 64-bit windows-installer custom-action

我有一个用C#编写的应用程序,它依赖于sqlite托管提供程序。 sqlite提供程序是依赖于平台的(有两个dll用于32位和64位具有相同名称的应用程序)。应用程序在运行时根据操作系统加载所需的一个。

问题在于,在创建安装程序时,我无法将64位模式dll添加到安装项目中,因为我收到以下错误:File '' targeting '' is not compatible with the project's target platform ''.

我会使用其他安装程序,但我有自定义操作,必须在安装过程中调用。

所以我想知道是否有一个安装程序可以让我添加32位和64位dll并执行用C#编写的自定义操作。

一种可能的解决方案是安装两个安装程序,但如果可能的话我想避免使用它。

有什么建议吗?

4 个答案:

答案 0 :(得分:6)

Inno Setup安装程序支持您请求的功能,此安装程序非常灵活可靠,在Web中存在许多脚本示例,以根据最终客户端的体系结构进行条件安装。

检查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;

答案 1 :(得分:1)

使用Windows Installer,没有。你需要两个设置。

但是NSIS能够在运行时检测的单个设置中处理这两个平台。这取决于您是否针对企业用户,企业客户将需要Windows Installer(MSI)软件包,而普通的互联网用户并不关心:)

答案 2 :(得分:1)

我喜欢Inno设置的想法,我可能会尝试一下,但请考虑以下内容:

Microsoft MSI最佳实践是进行2个单独设置,一个用于32个,一个用于64个,而许多第三方IDE(如Installshield)支持这些最佳实践。国际海事组织可能有这样的原因,否则他们会增加这一功能,以超越竞争对手。

要从单个安装项目构建2个设置,您必须使用版本标记构建两个安装程序,使用版本标记,基本上创建一个包含32位程序集的功能,另一个包含64位程序集,分配向每个版本发布标记,并单独构建每个版本,

所以在构建时,你构建32位版本,它是打包的,而64位被忽略,那么你对64位做同样的事情。如果需要,您可以通过命令行参数传递这些标志。

这样您就无需维护重复的设置代码。

答案 3 :(得分:1)

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