简体   繁体   English

防止使用 WIX 的 PROCESSOR_ARCHITECTURE 环境变量在 x64 上安装 32 位 WIX 安装程序

[英]Prevent to install 32 bit WIX installer on x64 using PROCESSOR_ARCHITECTURE Enviroment variables of WIX

I have a Wix Setup msi for both 32 bit and 64 bit platform.我有一个适用于 32 位和 64 位平台的 Wix Setup msi。
I want to prevent it to install 32 bit msi on 64 bit OS and 64 bit msi on 32 bit OS.我想阻止它在 64 位操作系统上安装 32 位 msi,在 32 位操作系统上安装 64 位 msi。
Although WIX prevent to install 64 bit msi on 32 bit msi but i want to achieve reverse also.虽然 WIX 阻止在 32 位 msi 上安装 64 位 msi,但我也想实现反向。

I was using the below code :-我正在使用以下代码:-

<?if $(var.Platform)=x86 ?>
<Condition Message="Setup can not be installed on x64 machine.">
  <![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>

but it display at the welcome page of my msi.但它显示在我的 msi 的欢迎页面上。 I want to display the message same as i get when i install 64 bit msi on 32 bit os such as我想显示与我在 32 位操作系统上安装 64 位 msi 时得到的消息相同的消息,例如

The Installation Package is not supported by this processor type.Contact your support personnel此处理器类型不支持安装包。请联系您的支持人员

How can i achieve this?我怎样才能做到这一点?

That condition should work!那个条件应该有效! I'm thinking maybe the variable Platform is not being set properly.我在想可能变量 Platform 没有正确设置。

You could also try this (which is pretty much the same as yours):你也可以试试这个(这和你的几乎一样):

    <?if $(var.Platform) = x86 ?>
        <Condition Message="Setup can not be installed on x64 machine.">
            <![CDATA[Not VersionNT64]]>
        </Condition>
    <?endif?>

Edit : I removed the Platform=x64 condition after @Christopher Painter comment because you get that for free on x64 msis.编辑:我在@Christopher Painter 评论后删除了 Platform=x64 条件,因为您可以在 x64 msis 上免费获得它。 I also tried the code above and it works.我也尝试了上面的代码并且它有效。

I don't believe you can get the exact same behavior as running the x64 MSI on an x86 system.我不相信您可以获得与在 x86 系统上运行 x64 MSI 完全相同的行为。 In that case, Windows itself is checking the MSI architecture before it tries to run it and displaying the message.在这种情况下,Windows 本身会在尝试运行它并显示消息之前检查 MSI 体系结构。 You've invented your own unnecessary restriction so you can't use the exact same method as Windows.你发明了你自己不必要的限制,所以你不能使用与 Windows 完全相同的方法。

However I don't know why you are seeing your message on your welcome page.但是我不知道为什么您会在欢迎页面上看到您的消息。 All the launch conditions I have seen are a dialog box that Windows supplies (where you click OK) and then you usually see a dialog saying that the install failed (but again, that failure dialog is up to you).我看到的所有启动条件都是 Windows 提供的对话框(您在其中单击“确定”),然后您通常会看到一个说安装失败的对话框(但同样,该失败对话框取决于您)。 So you should be able to get something close to what Windows does.所以你应该能够得到一些接近于 Windows 所做的事情。

Small improvement would be to use the buildarch enviroment instead of a variable小的改进是使用 buildarch 环境而不是变量

<?if $(sys.BUILDARCH) = x86 ?>
    <Condition Message="Setup can not be installed on x64 machine.">
       <![CDATA[Not VersionNT64]]>
    </Condition>
<?endif?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM