安装程序根据目标系统安装32位或64位版本的应用程序 [英] Setup program to install 32 or 64 bit version of application depending on target system

查看:157
本文介绍了安装程序根据目标系统安装32位或64位版本的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有C ++的Visual Studio 2008和内置的设置工具。有没有办法创建一个安装项目,在64位目标机器/操作系统上安装64位应用程序,在32位目标机器/操作系统上运行32位版本?

I'm using Visual Studio 2008 with C++ and the built in setup facility. Is there any way to create a setup project that will install a 64 bit application on a 64 bit target machine / OS and a 32 bit version when run on on a 32 bit target machine / OS?

推荐答案

如果您使用基于MSI的技术(基于Microsoft Installer及其API),您将获得由其目标指令集架构标记的MSI,一个32-位和至少两个不兼容的64位。 32位MSI可以安装在任何平台上,但是32位系统将无法安装针对任何其他指令集架构的MSI。



因此,看起来唯一的选择是为不同的架构生成2或3个不同的MSI。 (我只使用WiX框架;如果你有兴趣如何在一个项目中完成它,我可以解释它。)通常的做法是让Setup.EXE确定当前平台的体系结构并运行其中一个可用的MSI,具体取决于它(或者它可以在有效的某些选项之间进行选择;可以将应用程序安装为针对本机64位平台,如同针对64位平台的32位,可以在WoW64上运行)。



(请参阅: http://en.wikipedia.org/wiki/WoW64 [ ^ ]。)



也许我不知道什么,但我看到某种缺陷:它看起来像MSI系统无法解决安装.NET产品的问题由于使用JIT编译,可以在.NET中使用AnyCPU。 Java也是如此。您实际上可以使用32位MSI安装AnyCPU产品,但缺点是:产品将安装到Program Files(x86),这不是很有效。有趣的是,如果您的MSI允许自定义目标目录(强烈推荐)并且用户将其删除(x86),则安装后仍会将其更改为64位平台上的Program Files(x86)!多么蹩脚!该应用程序仍然作为本机64位应用程序。这是为不同的体系结构提供不同MSI的另一个原因,即使对于纯粹的AnyCPU项目也是如此。很丑,但效果更好。



-SA
If you are using MSI-based technology (based on Microsoft Installer and its API), you obtain MSI which is marked by its target instruction-set architecture, one 32-bit and at least two incompatible 64-bit ones. A 32-bit MSI can be installed on any platform, but a 32-bit system won't be able to install MSIs targeted to any other instruction-set architecture.

So, it looks like the only option is to generate 2 or 3 different MSIs for different architectures. (I use only WiX framework; if you are interested how to do it in one project, I can explain it.) The usual practice is to have Setup.EXE which determines the current platform's architecture and run one of the available MSIs depending on it (or it may provide a choice between valid some options; an application can be installed as targeted to native 64-bit platform, as as a 32-bit for 64-bit platform, to be run on WoW64).

(Please see: http://en.wikipedia.org/wiki/WoW64[^].)

Maybe I don't know something, but I see some kind of defect in it: it looks like MSI system cannot address such thing as installation of the .NET products targeted to "AnyCPU", which is possible in .NET, due to the use of JIT compilation. The same goes for Java. You can actually install the "AnyCPU" product using 32-bit MSI, but the defect is: the product will be installed to "Program Files (x86)", which is not quite valid. Interestingly, if your MSI allows for custom target directory (highly recommended) and the user removed it " (x86)", the installed still changes it to "Program Files (x86)" on the 64-bit platforms again! What a lame! The application still works as native 64-bit one. This is yet another reason to have different MSIs for different architectures even for a pure "AnyCPU" project. Ugly, but works more correctly.

—SA


这篇关于安装程序根据目标系统安装32位或64位版本的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆