WiX:防止 32 位安装程序在 64 位 Windows 上运行

发布于 2024-08-25 08:56:31 字数 734 浏览 2 评论 0原文

由于用户混淆,我们的应用程序需要针对 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?>

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

Due to user confusion, our app requires separate installers for 32-bit and 64-bit versions of Windows. While the 32-bit installer runs fine on win64, it has the potential to create support headaches and we would like to prevent this from happening.

I want to prevent the 32-bit MSI installer from running on 64-bit Windows machines. To that end I have the following condition:

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

With the Win64 defined like this:

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

Thing is, I can't get this check to work right. Either it fires all the time, or none of the time. The goal is to check presence of the run-time msix64 variable against the compile-time Win64 variable and throw an error if these don't line up, but the logic is not working how I intend it to. Has anyone come up with a better solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我的痛♀有谁懂 2024-09-01 08:56:32

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

Include the Condition element only in your 32-bit package (i.e., using ?if? preprocessor statement). The Condition would be "NOT Msix64": Launch conditions are things that must be true, so if Msix64 is set, the launch condition would fail and that means it's an x64 OS and a 32-bit package and the correct thing to do is to block.

北方的韩爷 2024-09-01 08:56:32

我们使用以下...

<?if $(var.ProcessorArchitecture)=x86 ?>
<Condition Message="!(loc.LaunchCondition_Error64)">
    <![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>

We use the following...

<?if $(var.ProcessorArchitecture)=x86 ?>
<Condition Message="!(loc.LaunchCondition_Error64)">
    <![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>
各自安好 2024-09-01 08:56:32

条件元素与安装过程中存在的 Windows 安装程序属性一起使用。

但是,您将 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) 有正确的值,那么这将导致“Win64”属性被记录在 Windows 安装程序数据库中(即MSI 文件),并且该属性将在安装期间可用,以便在条件元素中使用。

The condition element works with windows installer properties, which exist during an installation.

However, you are defining a Win64 as a wix variable, not a windows installer property. Wix variables only exist while the setup is created. You have to reference them as $(var.MyWixVariable) where you use them, and the wix preprocessor will then replace them with their defined value.

I would try this instead:

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

If $(var.Platform) has the right value when the setup is created, then this will cause a "Win64" property to be recorded in the windows installer database (i.e. the MSI file) and the property will be available during installation for use in a condition element.

舞袖。长 2024-09-01 08:56:32

添加此条件

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

您可以使用 32 位组件和 64 位组件创建一个安装程序,并将这两个条件放入相应的组件中,

<Component Id="bit32Component" Guid="..." Feature="ProductFeature">
    <Condition>%PROCESSOR_ARCHITECTURE~="x86" AND %PROCESSOR_ARCHITEW6432<>"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

Add this condition

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

You could create one installer with a 32bit component and a 64bit component and put these two conditions in the respective components

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

here is a reference I used

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文