WiX 3.0 中的平台识别 [英] Platform identification in WiX 3.0

查看:26
本文介绍了WiX 3.0 中的平台识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将托管代码从 x86 迁移到 x64 平台时遇到问题.我有一个 WiX 项目来创建将通过 Bootstrapper 执行的 MSI.

I am facing issues when migrating the managed code from x86 to x64 platform. I have a WiX project to create an MSI which will be executed through Bootstrapper.

在 x86 平台上,根据 Project.wxs 文件将文件复制到程序文件"中.但是,如果通过 Bootstrapper 在 x64 平台上安装相同的 MSI,默认情况下,所有安装文件都会复制到Program Files (x86)"中,并且应用程序的功能失败,因为它在 12-hive 层次结构中找不到必要的文件程序文件(对于 64 位,它是C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12CONFIG").

On an x86 platform, files get copied in "Program Files" as per the Project.wxs file. But if the same MSI is installed on an x64 platform through Bootstrapper, all the installation files get copied by default in "Program Files (x86)" and the application’s functionality failed as it could not find the necessary files in the 12-hive hierarchy of Program Files (for 64-bit it is "C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12CONFIG").

我曾尝试使用预处理器变量,例如 <?if $(var.ProcessorArchitecture)=x64 ?>,但我需要在项目属性中将此变量硬编码为 x86 或 x64.最后,我为两个不同的平台提供了两个不同的 MSI,这对我来说不是一个理想的解决方案.

I have tried using preprocessor variables like <?if $(var.ProcessorArchitecture)=x64 ?>, but I need to hardcode this variable in the project property to either x86 or x64. Finally I end up with two different MSIs for two different platforms which is not a desirable solution for me.

那么,通过 WiX,是否可以识别平台以确保安装在所需位置?

So, through WiX, is it possible to identify the platform to ensure installation at the desired location?

推荐答案

我不相信您将能够拥有一个支持这两个平台的 MSI.您将需要为 x86 和另一个 x64 创建一个 - 好消息是您不需要维护另一个 WiX 项目来实现这一点.

I don't believe you will be able to have a single MSI that will support both platforms. You will need to create one for x86 and another x64 - the good news is that you don't need to maintain another WiX project to achieve this.

我过去这样做的方式是在您的产品定义的开头添加以下内容.

The way I've done this in the past is to have the following at the beginning of your product definition.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

    <?if $(var.Platform)=x64 ?>
      <?define msiProductId = "102F7DF4-19A6-4d3d-987F-FF57A2031593" ?>
      <?define win64Flag = "yes" ?>
    <?else ?>
      <?define msiProductId = "8AE46CAF-220F-4B9F-9527-D4A19A27C45B" ?>
      <?define win64Flag = "no" ?>
    <?endif ?>

    <Product Id="$(var.msiProductId)"
             Name="My Product"
             Language="1033"
             Version="1.0.0"
             Manufacturer="Acme"
             UpgradeCode="E2575E4A-A62E-4460-B96D-B722C79C8EAA">

        <Package InstallerVersion="400"
                 Compressed="yes"
                 InstallPrivileges="elevated"
                 Platform="$(var.Platform)"
        />

        <!-- Rest of product definition goes here -->

    </Product>
</Wix>

我忘记了我从哪里得到的为每个平台使用不同 ProductID 的建议.

I forget where I got the advice to use a different ProductID for each platform.

我创建了win64Flag"变量以使其他 WiX 元素在跨平台场景中正常工作.例如,以下是您如何使用它来使单个 RegistrySearch 定义适用于两个平台,并且应该可以解决您在定位 12-hive 层次结构时遇到的问题.

I created the 'win64Flag' variable to get other WiX elements to work nicely in the cross-platform scenarios. As an example, here's how you use it to make a single RegistrySearch definition work for both platforms and should resolve the issue you are having with locating the 12-hive hierarchy.

<Property Id="WSE12DIRECTORY">
    <RegistrySearch Id="Reg_WSE12DIRECTORY"
                    Type="raw"
                    Root="HKLM"
                    Key="SOFTWAREMicrosoftShared ToolsWeb Server Extensions12.0"
                    Name="Location"
                    Win64="$(var.win64Flag)"
    />
</Property>

所有这些都到位后,只需在 Candle 命令行,或在 Visual Studio 中选择目标平台.

With all this in place, then it is just a case of passing the relevant value for the 'Platform' pre-processor variable on the Candle command-line, or selecting the target platform in Visual Studio.

这篇关于WiX 3.0 中的平台识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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