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

发布于 2024-08-30 20:32:49 字数 446 浏览 3 评论 0原文

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

问题是,在创建安装程序时,我无法将 64 位模式 dll 添加到安装项目,因为出现以下错误: 文件“定位”与项目的目标平台“不兼容”。

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

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

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

有什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

云醉月微眠 2024-09-06 20:32:49

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;

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;
忘年祭陌 2024-09-06 20:32:49

对于 Windows Installer,则不会。您将需要两个设置。

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

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 :)

旧话新听 2024-09-06 20:32:49

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

Microsoft MSI 最佳实践是有 2 个单独的设置,一个用于 32 位,一个用于 64 位,并且许多第 3 方 IDE(如 Installshield)认可这些最佳设置做法。在我看来,这可能是有原因的,否则他们会添加此功能以比竞争对手更具优势。

要从单个安装项目构建 2 个安装程序,您需要从同一个安装项目构建两个安装程序,使用发布标志,您基本上创建一个包含 32 位程序集的功能,另一个包含 64 位程序集的功能,为并分别构建每个版本,

因此在构建时,您构建 32 位版本,将其打包,而 64 位版本将被忽略,然后您对 64 位执行相同的操作。如果需要,您可以通过命令行参数传递这些标志。

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

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.

一抹淡然 2024-09-06 20:32:49

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文