18

由于用户的困惑,我们的应用程序需要单独的安装程序用于 32 位和 64 位版本的 Windows。虽然 32 位安装程序在 win64 上运行良好,但它可能会造成支持问题,我们希望防止这种情况发生。

我想阻止 32 位 MSI 安装程序在 64 位 Windows 机器上运行。为此,我有以下条件:

<Condition Message="You are attempting to run the 32-bit installer on a 64-bit version of Windows.">
  <![CDATA[Msix64 AND (NOT Win64)]]>
</Condition>

Win64 定义如下:

<?if $(var.Platform) = "x64"?>
<?define PlatformString = "64-bit"?>
<?define Win64 ?>
<?else?>
<?define PlatformString = "32-bit"?>
<?endif?>

问题是,我无法让这张支票正常工作。要么一直触发,要么不触发。目标是根据msix64编译时Win64变量检查运行时变量的存在,如果它们不对齐,则抛出错误,但逻辑无法按照我的预期工作。有没有人提出更好的解决方案?

4

4 回答 4

15

仅在您的 32 位程序包中包含 Condition 元素(即,使用 ?if? 预处理器语句)。条件将是“NOT Msix64”:启动条件是必须为真的事情,因此如果设置了 Msix64,启动条件将失败,这意味着它是 x64 操作系统和 32 位包,正确的做法是堵塞。

于 2010-03-17T17:19:08.997 回答
7

我们使用以下...

<?if $(var.ProcessorArchitecture)=x86 ?>
<Condition Message="!(loc.LaunchCondition_Error64)">
    <![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>
于 2010-03-18T01:10:29.540 回答
3

条件元素适用于安装期间存在的 Windows 安装程序属性。

但是,您将 a 定义Win64为 wix 变量,而不是 Windows 安装程序属性。Wix 变量仅在创建设置时存在。您必须$(var.MyWixVariable)在使用它们的位置引用它们,然后 wix 预处理器将用它们定义的值替换它们。

我会试试这个:

<?if $(var.Platform) = "x64"?>
<?define PlatformString = "64-bit"?>
<Property Id="Win64" Value="1" />
<?else?>
<?define PlatformString = "32-bit"?>
<?endif?>

如果$(var.Platform)在创建设置时具有正确的值,那么这将导致在 Windows 安装程序数据库(即 MSI 文件)中记录一个“Win64”属性,并且该属性将在安装期间可用于条件元素。

于 2010-03-17T00:29:58.937 回答
3

添加这个条件

<Condition Message="This is designed for 32bit OS">%PROCESSOR_ARCHITECTURE ~= "x86" AND %PROCESSOR_ARCHITEW6432 &lt;&gt; "amd64"></Condition>

您可以创建一个具有 32 位组件和 64 位组件的安装程序,并将这两个条件放在各自的组件中

<Component Id="bit32Component" Guid="..." Feature="ProductFeature">
    <Condition>%PROCESSOR_ARCHITECTURE~="x86" AND %PROCESSOR_ARCHITEW6432&lt;&gt;"amd64"></Condition>
</Component>
<Component Id="bit64Component" Guid="..." Feature="ProductFeature">
    <Condition>%PROCESSOR_ARCHITECTURE~="amd64" OR %PROCESSOR_ARCHITEW6432~="amd64"></Condition>
</Component>

这是我使用的参考

http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx

于 2010-03-17T11:45:12.243 回答