7

我的发射条件怎么了?它应该阻止 x86 安装程序在 64 位系统上运行,但它似乎没有效果。

<!-- Launch Condition to check that x64 installer is used on x64 systems -->
<Condition Message="64-bit operating system was detected, please use the 64-bit installer.">
  <![CDATA[VersionNT64 AND ($(var.Win64) = "no")]]>
</Condition>

var.Win64派生自 MSBuild 变量,如下所示:

  <!-- Define platform-specific names and locations -->
  <?if $(var.Platform) = x64 ?>
  <?define ProductName = "$(var.InstallName) (x64)" ?>
  <?define Win64 = "yes" ?>
  <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
  <?define PlatformCommonFilesFolder = "CommonFiles64Folder" ?>
  <?else ?>
  <?define ProductName = "$(var.InstallName) (x86)" ?>
  <?define Win64 = "no" ?>
  <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
  <?define PlatformCommonFilesFolder = "CommonFilesFolder" ?>
  <?endif ?>

我想解决我的问题,但我也有兴趣了解解决此类问题的策略。

4

1 回答 1

9

根据LaunchCondition 表定义:

必须评估为 True 才能开始安装的表达式。

您的条件由两部分组成:第一个在安装时评估,另一个在构建时评估。因此,对于 x86 包,条件的第二部分将在构建时评估为“no”=“no”,这显然在安装时给出了 True。第一部分 - VersionNT64 - 在 x64 机器上定义(因此为 True)。这就是为什么整个条件为 True 并开始安装的原因。

您可以按如下方式重写您的条件:

<Condition Message="64-bit operating system was detected, please use the 64-bit installer.">
  <?if $(var.Win64) = "yes" ?>
    VersionNT64
  <?else?>
    NOT VersionNT64
  <?endif?>
</Condition>

因此,在 64 位软件包中,条件将是 just VersionNT64,并且将通过并开始安装。形成 x86 包的条件将是NOT VersionNT64,这显然会在 64 位上失败,但在 32 位上启动。

于 2011-08-12T07:32:21.297 回答