简体   繁体   中英

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.
I want to prevent it to install 32 bit msi on 64 bit OS and 64 bit msi on 32 bit OS.
Although WIX prevent to install 64 bit msi on 32 bit msi but i want to achieve reverse also.

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. I want to display the message same as i get when i install 64 bit msi on 32 bit os such as

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.

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. 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. In that case, Windows itself is checking the MSI architecture before it tries to run it and displaying the message. You've invented your own unnecessary restriction so you can't use the exact same method as 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). So you should be able to get something close to what Windows does.

Small improvement would be to use the buildarch enviroment instead of a variable

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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