如何根据处理器体系结构类型(32位或64位)有条件地安装组件? [英] How to conditionally install components based on processor architecture type (32-bit or 64-bit)?

查看:65
本文介绍了如何根据处理器体系结构类型(32位或64位)有条件地安装组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用InstallShield 2009,基本MSI项目,需要根据处理器架构类型(32位或64位)有条件地安装一些文件位)。我创建了两个独立的组件FILES64和FILES32,其中包含必要的文件,需要在INSTALLDIR上有条件地复制文件。



ie

IF(32 -BB>

安装文件32

ELSE

安装文件64





我尝试使用Condition对话框选择组件的Condition属性。但是,我找不到一个说明32位或64位的installshield属性。任何人都可以帮忙吗?



谢谢,

CB

Hi,

I am using InstallShield 2009, Basic MSI project and need to install some of the files conditionally based on processor architecture type (32-bit or 64-bit). I created two separate components FILES64 and FILES32 which contains necessary files and need to copy the files conditionally on INSTALLDIR.

i.e.
IF (32-bit) THEN
INSTALL FILES32
ELSE
INSTALL FILES64


I tried to select Condition property of the component using Condition dialog. However, I cannot find an installshield property that states 32-bit or 64-bit. Can anyone help here?

Thanks,
CB

推荐答案

让我首先回答问题评论中提到的两个问题中的第一个问题。 (请参阅所有讨论。)



我建议使用Microsoft开源WiX,因为这是一个非常合法的产品。它符合Visual Studio插件的要求;它自己的安装程序实际上是在三个最新版本(目前)的Visual Studio上安装它。更重要的是,它为MSBuild提供了正确的接口,这实际上是一个公共多平台标准。甚至Visual Studio附带的现有安装项目也不是合法的MSBuild项目类型;从Visual Studio v.2012开始,它被排除在捆绑包之外。



请参阅:

http://en.wikipedia.org/wiki/WiX [ ^ ],

http://wixtoolset.org/ [ ^ ]。



这是文档和教程:

http://wix.sourceforge.net /manual-wix3/main.htm [ ^ ],

http://wix.tramontana.co.hu/tutorial [ ^ ]。



现在,第一个问题是关于某些文件系统对象的权限更改。例如,假设您要设置某个目录的权限,并使其对所有用户进行读/写。诀窍是:您必须使用显式< CreateFolder> 声明。通常,目录和文件仅相对于顶级目标目录(从一组预定义的合法目的地中选择)创建,并且它们是隐式创建的。您需要为已声明的目录使用< CreateFolder> 节点的原因是它允许子节点< Permission> 。这是样本声明的外观。在此示例中,我假设在表示所有用户数据的某个目录中更改了权限,这是非常典型的情况:



Let me first answer to the first of the two question mentioned in the comments to the question. (Please see all the discussion.)

I recommend using Microsoft open-source WiX because this is a really legitimate product. It meets the requirements for Visual Studio add-on; and its own installer actually installs it on Visual Studio of three latest versions (currently). More importantly, it presents correct interface to MSBuild, which is actually a public multiplatform standard. Even the existing "Setup project" which comes with Visual Studio is not a legitimate MSBuild project type; it is excluded from a bundle as of Visual Studio v.2012.

Please see:
http://en.wikipedia.org/wiki/WiX[^],
http://wixtoolset.org/[^].

This is the documentation and tutorial:
http://wix.sourceforge.net/manual-wix3/main.htm[^],
http://wix.tramontana.co.hu/tutorial[^].

Now, the first question was about the permission change in some file system object. For example, let's assume you want to set permission of some directory, and make it read/write of all users. The trick is: you have to use explicit <CreateFolder> declaration. Normally, directories and files are only created relative to the top-level target directory (which is selected from a predefined set of legal destinations), and they are created implicitly. The reason you need to use <CreateFolder> node for already declared directory is that it allows the child node <Permission>. This is how a sample declaration could look. In this sample, I assume that the permission is changed in some directory representing "All users" data, which is the very typical case:

<DirectoryRef Id="AppDataLevel3">
    <Component Id="DataFiles" Guid="19DC5B16-B3E1-4e5d-A8B4-BF0FADA6AC5A">
        <File Id="ApplicationFile4" Source="SourceFiles/WiX.Very-specal-file.txt"/>
        <CreateFolder Directory="AppDataLevel2">
            <!-- only top level, down levels inherit -->
            <Permission User="Everyone" GenericAll="yes" />
        </CreateFolder>
    </Component>
</DirectoryRef>





在这里,你应该明白许多声明都在原始和参考表单,例如<目录> < DirectoryRef> < Component> < ComponentRef> ,所以 Id (参见上面的示例)是指具有相同 Id 的某些先前的< Directory> 声明。当您熟悉原始文档中的目录,文件和组件的声明时,这应该是非常清楚的。



现在,我使用了某些用户 GenericAll 属性以选择目标权限。您可以了解其他选项,例如,来自... Intellisense。是的,当用作Visual Studio插件时,WiX支持Intellisense。



您还需要确保安装过程请求提升的权限,因为更改权限需要它。为此,您必须在安装项目的第二个最顶层指定它,在< Product> 元素下:



Here, you should understand that many declaration comes in "original" and "Ref" forms, such as <Directory> and <DirectoryRef> or <Component> and <ComponentRef>, so the Id (see the sample above) refers to some prior <Directory> declaration with the same Id. When you get familiar with declarations of Directories, Files and Components from the original documentation, this should be quite clear to you.

Now, I used certain User and GenericAll attributes to chose the target permission. You can learn what are other options, for example, from… Intellisense. Yes, WiX supports Intellisense when used as a Visual Studio add-on.

You also need to make sure the installation process requests the elevated privileges, because changing permission requires it. For this purpose, you have to specify it on the second topmost level of the installation project, under the <Product> element:

<Product Id="*" ... >

    <Package InstallerVersion="200" InstallPrivileges="elevated" Compressed="yes" ... />
    <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />

    <!-- ... -->

</Product>





您的第二个问题是关于指令集架构。语法非常简单易于查找,但我会考虑如何解释它以避免常见的混淆。我稍后再说吧正如我上面所说,我需要更多的业余时间来做这件事。



这个第一个答案应该足以开始了。关于第二部分 - 我答应了......



-SA


现在我正在给予处理器指令集架构的承诺答案以及不同架构对安装的影响。



首先,了解可用的架构及其名称是很好的,因为它们的命名令人困惑。据我所知,Windows安装程序目前适用于使用以下3种体系结构的系统:x86,x86-64(AMD64)和Itanium(IE64)。它们都是不兼容的,但两个64位处理器都运行x86 32位进程,这在Windows上通过WoW64支持。请参阅:

http://en.wikipedia.org/wiki/Instruction_set [< a href =http://en.wikipedia.org/wiki/Instruction_settarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/X86 [ ^ ],

http://en.wikipedia.org/wiki/X86-64 [ ^ ],

http://en.wikipedia.org/wiki / Itanium [ ^ ],

http://en.wikipedia.org/wiki/WoW64 [ ^ ]。



最常见的64这些天的-bit架构是x86-64,但很多人称之为64位或x64,但这不是原始的64位架构,实际上是IE64,现在通常被称为Itanium。更便宜和更常见的x86-64架构最初由AMD(因此AMD64)开发,作为x86的扩展,后来被英特尔所接受,后者保留了原有的IE64,用于更昂贵的更高级系统。这通常会产生各种混淆。



使用WiX构建的安装在运行时检测架构的方法之一是检查环境变量 PROCESSOR_ARCHITECTURE ,因此结果将取决于Windows如何在相应变量中命名这些体系结构。这些架构以下列名称为人所知:x86,AMD64和IE64



MSBuild和Visual Studio术语是不同的。相同体系结构的名称是x86,x64和Itanium。并且,使用术语平台而不是术语指令集架构。我们需要使用以下信息。



您可以使用WiX < Condition> 元素,可以是元素< Component> 的子元素。因此,您可以区分要在组件级别安装的文件。 (对于可以使用子元素< Condition> 的其他可能元素,请参阅下面的链接。)它看起来像这样:

Now I'm giving the promised answer on the processor instruction-set architecture and the implication of different architectures on installation.

First of all, it's good to know the available architectures and their names, as their naming is confusing. To best of my knowledge, Windows installer is presently applicable to the systems using the following 3 architectures: x86, x86-64 (AMD64) and Itanium (IE64). They are all incompatible, but both 64-bit processors run x86 32-bit processes, and this is supported on Windows via WoW64. Please see:
http://en.wikipedia.org/wiki/Instruction_set[^],
http://en.wikipedia.org/wiki/X86[^],
http://en.wikipedia.org/wiki/X86-64[^],
http://en.wikipedia.org/wiki/Itanium[^],
http://en.wikipedia.org/wiki/WoW64[^].

The most usual 64-bit architecture these days is x86-64, but many call it just 64-bit or x64, but this is not an original 64-bit architecture, which is actually IE64, these days usually known as Itanium. The cheaper and more usual x86-64 architecture was originally developed by AMD (hence "AMD64") as the extension of x86, and later embraced by Intel who preserved its original IE64 for more expensive higher level systems. This all often creates all kinds of confusions.

One of the ways to detect the architecture during runtime using the installation built with WiX is to check up the environment variable PROCESSOR_ARCHITECTURE, so the results will depend on how Windows name those architectures in the correspondent variable. The architectures are known under the following names: "x86", "AMD64" and "IE64".

The MSBuild and Visual Studio terminology is different. The names of the same architectures are "x86", "x64" and "Itanium". And, instead of the term "instruction-set architecture", the term "Platform" is used. We will need to use this information below.

You can identify the system operating during installation runtime using WiX <Condition> element, which can be a child of the element <Component>. Therefore, you discriminant the files to be installed at the level of components. (For other possible elements which can use the child element <Condition>, please see the link below.) It can look like that:
<DirectoryRef Id="CUSTOM.INSTALLATION.DIRECTORY">
   <Component Id="ApplicationFiles64" Guid="{4A91A21D-FC99-419C-8144-211DE78014C6}">
      <File Id="ApplicationFile1" Source="SourceFiles/Some-x86-file.dll" />
      <Condition> %PROCESSOR_ARCHITECTURE="x86" </Condition>
   </Component>
   <Component Id="ApplicationFiles64" Guid="{E59BB1E9-9B56-4355-BCDC-F03501D326A8}">
      <File Id="ApplicationFile1" Source="SourceFiles/Some-x86-64-file.dll" />
      <Condition> %PROCESSOR_ARCHITECTURE="AMD64" </Condition>
   </Component>
   <Component Id="ApplicationFiles64" Guid="{1AD7798A-BE64-4063-AD31-7F386371A150}">
      <File Id="ApplicationFile1" Source="SourceFiles/Some-IE64-file.dll" />
      <Condition> %PROCESSOR_ARCHITECTURE="IE64" </Condition>
   </Component>
</DirectoryRef>




当然,组件可以包含任意数量的文件和操作。顺便说一句,不要忘记每次语法需要时都应生成完整的唯一GUID。



请参阅:

http://wix.sourceforge.net/manual-wix2/wix_xsd_condition.htm [ ^ ],

http://wix.sourceforge.net/manual-wix2/wix_xsd_component.htm [ ^ ]。



这不是您可以用来处理多平台/跨平台安装的唯一方法。当您可能想要为每个平台创建不同的MSI或组合这两种方法时,有很多原因。如果您使用MSBuild和/或Visual Studio,则可以很好地支持创建每个平台的MSI。支持它的标准方法是使用标准属性



Of course, a component can have any number of files and actions. By the way, don't forget that you should generate the whole unique GUID every time it is required by the syntax.

Please see:
http://wix.sourceforge.net/manual-wix2/wix_xsd_condition.htm[^],
http://wix.sourceforge.net/manual-wix2/wix_xsd_component.htm[^].

This is not the only approach you can use to approach multiplatform/cross-platform installation. There is a number of reasons when you may want to create different MSI of each platform or combine both approaches. The creation of per-platform MSI is well supported if you use MSBuild and/or Visual Studio. The standard way to support it is to use the standard properties


(平台)
(Platform) and


这篇关于如何根据处理器体系结构类型(32位或64位)有条件地安装组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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