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

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

问题描述

将托管代码从x86迁移到x64平台时,我遇到了问题。我有一个WiX项目,用于创建一个 MSI ,该项目将通过Bootstrapper执行。

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,则默认情况下,所有安装文件都将复制到程序文件(x86)中,并且该应用程序的功能失败,因为它无法在12个蜂巢的层次结构中找到所需的文件。程序文件(对于64位,是 C:\Program Files\Common Files\Microsoft Shared\Web服务器扩展\12\CONFIG)。

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 Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG").

我尝试使用<?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个蜂巢层次结构时遇到的问题。

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="SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.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天全站免登陆