Run the condition to ensure that the 64-bit installer is used on a 64-bit system

What about my startup state? It should have prevented the x86 installer from running on a 64-bit system, but it seems to have no effect.

<!-- 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 is derived from MSBuild variables as follows:

  <!-- 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 ?> 

I would like to solve my problem, but I would also be interested in learning about strategies for resolving this problem.

+7
source share
1 answer

According to the LaunchCondition table :

An expression that must be evaluated in True to begin the installation.

Your condition consists of two parts: the first is evaluated during installation, the other is evaluated during assembly. Thus, for the x86 package, the second part of the condition will evaluate the value "no" = "no" during the build, which obviously gives True during installation. And the first part - VersionNT64 - is defined (and therefore True) on x64 machines. That is why the whole condition is True and the installation begins.

You can rewrite your condition as follows:

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

Therefore, in a 64-bit package, the condition will be just VersionNT64 , and it will pass and begin the installation. Form x86 package will be NOT VersionNT64 , which will obviously fail on 64-bit, but will start from 32-bit.

+7
source

All Articles