Skip to content

Commit

Permalink
Use WIX_NATIVE_MACHINE to detect native architecture of target machine (
Browse files Browse the repository at this point in the history
#8000) (#8003)

* Use WIX_NATIVE_MACHINE to detect native architecture of target machine

* Reference WIX_NATIVE_MACHINE property
  • Loading branch information
ericstj authored Oct 7, 2021
1 parent 08ae806 commit e58cb82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/Common/wix/dotnethome_x64.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,28 @@
<?define Platform = "$(sys.BUILDARCH)"?>
<?endif?>

<!-- InstallerArchitecture matches the expected values for PROCESSOR_ARCHITECTURE
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<!-- InstallerNativeMachine matches the expected values for image file machine constants
https://docs.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants -->
<?if $(var.Platform)~=x86?>
<?define InstallerArchitecture="X86"?>
<?define InstallerNativeMachine=332?>
<?elseif $(var.Platform)~=x64?>
<?define InstallerArchitecture="AMD64"?>
<?define InstallerNativeMachine=34404?>
<?elseif $(var.Platform)~=arm64?>
<?define InstallerArchitecture="ARM64"?>
<?define InstallerNativeMachine=43620?>
<?else?>
<?error Unknown platform, $(var.Platform) ?>?
<?error Unknown platform, $(var.Platform) ?>
<?endif?>

<Fragment>
<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE does not match the installer architecture
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<!-- Identify when installing in emulation as when WIX_NATIVE_MACHINE does not match the installer
native machine (where supported). Also detect running under WOW on x86 using VersionNT64,
since WIX_NATIVE_MACHINE cannot be retrieved on older Windows builds. -->
<PropertyRef Id="WIX_NATIVE_MACHINE" />
<SetProperty Action="Set_NON_NATIVE_ARCHITECTURE" Id="NON_NATIVE_ARCHITECTURE" Value="true" Before="CostFinalize">
NOT %PROCESSOR_ARCHITECTURE="$(var.InstallerArchitecture)"
<?if $(var.Platform)~=x86?>
VersionNT64 OR
<?endif?>
WIX_NATIVE_MACHINE AND NOT WIX_NATIVE_MACHINE="$(var.InstallerNativeMachine)"
</SetProperty>
</Fragment>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public override bool Execute()
// Add WiX extensions
light.Extensions.Add("WixDependencyExtension");
light.Extensions.Add("WixUIExtension");
light.Extensions.Add("WixUtilExtension");

if (!light.Execute())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
// Add WiX extensions
light.Extensions.Add("WixDependencyExtension");
light.Extensions.Add("WixUIExtension");
light.Extensions.Add("WixUtilExtension");

if (!light.Execute())
{
Expand Down

0 comments on commit e58cb82

Please sign in to comment.