Skip to content

Commit df4dff1

Browse files
authored
Merge pull request #11843 from ericstj/x64onARM64
Retarget DOTNETHOME when installing x64 on ARM64
2 parents e8274de + 4ce025c commit df4dff1

File tree

9 files changed

+136
-16
lines changed

9 files changed

+136
-16
lines changed

src/redist/targets/packaging/windows/clisdk/bundle.wxs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
Compressed="yes">
1212

1313
<bal:Condition Message="The installation path for x64 SDK installations: &quot;[DOTNETHOME_X64]&quot; cannot be the same as for x86 SDK installations: &quot;[DOTNETHOME_X86]&quot;">
14-
WixBundleInstalled OR ((NOT (DOTNETHOME_X64 ~= DOTNETHOME_X86)) OR DOTNETHOMESIMILARITYCHECKOVERRIDE)
14+
WixBundleInstalled OR (NOT DOTNETHOME_X64 ~= DOTNETHOME_X86) OR DOTNETHOMESIMILARITYCHECKOVERRIDE
1515
</bal:Condition>
1616

1717
<bal:Condition Message="The installation path for ARM64 SDK installations: &quot;[DOTNETHOME_ARM64]&quot; cannot be the same as for x86 SDK installations: &quot;[DOTNETHOME_X86]&quot;">
18-
WixBundleInstalled OR ((NOT (DOTNETHOME_ARM64 ~= DOTNETHOME_X86)) OR DOTNETHOMESIMILARITYCHECKOVERRIDE)
18+
WixBundleInstalled OR (NOT DOTNETHOME_ARM64 ~= DOTNETHOME_X86) OR DOTNETHOMESIMILARITYCHECKOVERRIDE
19+
</bal:Condition>
20+
21+
<!-- Permit same path on non-ARM64 machines since past SDKs always wrote this value -->
22+
<bal:Condition Message="The installation path for ARM64 SDK installations: &quot;[DOTNETHOME_ARM64]&quot; cannot be the same as for x64 SDK installations: &quot;[DOTNETHOME_X64]&quot;">
23+
WixBundleInstalled OR (NOT DOTNETHOME_ARM64 ~= DOTNETHOME_X64) OR (NOT NativeProcessorArchitecture=&quot;ARM64&quot;) OR DOTNETHOMESIMILARITYCHECKOVERRIDE
1924
</bal:Condition>
2025

2126
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.Foundation">
@@ -27,7 +32,7 @@
2732
<PayloadGroupRef Id="DotnetCoreBAPayloads" />
2833
</BootstrapperApplicationRef>
2934

30-
<swid:Tag Regid="microsoft.com" InstallPath="[DOTNETHOME]" />
35+
<swid:Tag Regid="microsoft.com" InstallPath="[$(var.Program_Files)]dotnet" />
3136

3237
<util:RegistrySearch Id="CheckDotnetInstallLocation_x86"
3338
Variable="DotnetInstallLocationExists_x86"
@@ -56,7 +61,7 @@
5661
Variable="DOTNETHOME_X86"
5762
Path="[ProgramFilesFolder]dotnet"/>
5863

59-
<?if $(var.Platform)=x64?>
64+
<?if $(var.Platform)!=x86?>
6065
<util:RegistrySearch Id="CheckDotnetInstallLocation_x64"
6166
Variable="DotnetInstallLocationExists_x64"
6267
Result="exists"
@@ -71,11 +76,21 @@
7176
Root="HKLM"
7277
Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64"
7378
Value="InstallLocation" />
79+
80+
<!-- Determine native OS architecture -->
81+
<util:RegistrySearch Id="CheckProcessorArchitecture_x64"
82+
After="DotnetInstallLocation_x64"
83+
Variable="NativeProcessorArchitecture"
84+
Result="value"
85+
Root="HKLM"
86+
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
87+
Value="PROCESSOR_ARCHITECTURE" />
7488

89+
<!-- Check default location when on x64 OS-->
7590
<util:FileSearch Id="DotnetExeSearch_x64"
76-
After="DotnetInstallLocation_x64"
91+
After="CheckProcessorArchitecture_x64"
7792
Variable="DotnetExeExists_x64"
78-
Condition="NOT DotnetInstallLocationExists_x64"
93+
Condition="NOT DotnetInstallLocationExists_x64 AND NativeProcessorArchitecture=&quot;AMD64&quot;"
7994
Result="exists"
8095
Path="[ProgramFiles64Folder]dotnet\dotnet.exe"/>
8196
<util:DirectorySearch Id="DotnetExeLocation_x64"
@@ -84,7 +99,20 @@
8499
Variable="DOTNETHOME_X64"
85100
Path="[ProgramFiles64Folder]dotnet"/>
86101

87-
<?elseif $(var.Platform)=arm64?>
102+
<!-- Check alternate location on non-x64 OS -->
103+
<util:FileSearch Id="DotnetExeSearch_alt_x64"
104+
After="CheckProcessorArchitecture_x64"
105+
Variable="DotnetExeExists_alt_x64"
106+
Condition="NOT DotnetInstallLocationExists_x64 AND NOT NativeProcessorArchitecture=&quot;AMD64&quot;"
107+
Result="exists"
108+
Path="[ProgramFiles64Folder]dotnet\x64\dotnet.exe"/>
109+
<util:DirectorySearch Id="DotnetExeLocation_alt_x64"
110+
After="DotnetExeSearch_alt_x64"
111+
Condition="DotnetExeExists_alt_x64"
112+
Variable="DOTNETHOME_X64"
113+
Path="[ProgramFiles64Folder]dotnet\x64"/>
114+
<?endif?>
115+
<?if $(var.Platform)=arm64?>
88116
<util:RegistrySearch Id="CheckDotnetInstallLocation_arm64"
89117
Variable="DotnetInstallLocationExists_arm64"
90118
Result="exists"
@@ -121,9 +149,9 @@
121149
Example:
122150
dotnet-sdk-3.0.100-alpha1-009719-win-x64.exe /install DOTNETHOME_X64="D:\dotnet\x64" DOTNETHOME_X86="D:\dotnet\x86" /log "installation.log" /quiet /norestart
123151
-->
124-
<Variable Name="DOTNETHOME_X86" Type="string" Value="[ProgramFilesFolder]dotnet" bal:Overridable="yes" />
125-
<Variable Name="DOTNETHOME_X64" Type="string" Value="[ProgramFiles64Folder]dotnet" bal:Overridable="yes" />
126-
<Variable Name="DOTNETHOME_ARM64" Type="string" Value="[ProgramFiles64Folder]dotnet" bal:Overridable="yes" />
152+
<Variable Name="DOTNETHOME_X86" bal:Overridable="yes" />
153+
<Variable Name="DOTNETHOME_X64" bal:Overridable="yes" />
154+
<Variable Name="DOTNETHOME_ARM64" bal:Overridable="yes" />
127155
<Variable Name="DOTNETHOME" Type="string" Value="[DOTNETHOME_$(var.PlatformToken)]" bal:Overridable="no" />
128156
<Variable Name="BUNDLEMONIKER" Type="string" Value="$(var.ProductMoniker)" bal:Overridable="no" />
129157
<Variable Name="DOTNETSDKVERSION" Type="string" Value="$(var.NugetVersion)" bal:Overridable="no" />

src/redist/targets/packaging/windows/clisdk/dotnet.wxs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
<Property Id="NUGETVERSION" Value="$(var.NugetVersion)" />
3131
<WixVariable Id="WixUILicenseRtf" Value="$(var.MicrosoftEula)" />
3232

33-
<Property Id="DOTNETEXE">
34-
<DirectorySearch Id="DOTNETPATH" Path="[#DOTNETHOME]">
35-
<FileSearch Id="DOTNETEXESEARCH" Name="dotnet.exe" />
36-
</DirectorySearch>
37-
</Property>
38-
3933
<CustomActionRef Id="WixBroadcastEnvironmentChange" />
4034

4135
<CustomAction Id="PropertyAssignPrimeCacheAndTelemetry"
@@ -68,6 +62,10 @@
6862
</Directory>
6963
</Directory>
7064
</Directory>
65+
66+
<?if $(var.Platform)~=x64?>
67+
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
68+
<?endif?>
7169
</Fragment>
7270
<Fragment>
7371
<ComponentGroup Id="DotnetToolSetup">
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
3+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
4+
<?ifndef Platform?>
5+
<?define Platform = "$(sys.BUILDARCH)"?>
6+
<?endif?>
7+
8+
<!-- InstallerArchitecture matches the expected values for PROCESSOR_ARCHITECTURE
9+
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
10+
<?if $(var.Platform)~=x86?>
11+
<?define InstallerArchitecture="X86"?>
12+
<?elseif $(var.Platform)~=x64?>
13+
<?define InstallerArchitecture="AMD64"?>
14+
<?elseif $(var.Platform)~=arm64?>
15+
<?define InstallerArchitecture="ARM64"?>
16+
<?else?>
17+
<?error Unknown platform, $(var.Platform) ?>?
18+
<?endif?>
19+
20+
<Fragment>
21+
<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE does not match the installer architecture
22+
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
23+
<SetProperty Action="Set_NON_NATIVE_ARCHITECTURE" Id="NON_NATIVE_ARCHITECTURE" Value="true" Before="CostFinalize">
24+
NOT %PROCESSOR_ARCHITECTURE="$(var.InstallerArchitecture)"
25+
</SetProperty>
26+
</Fragment>
27+
28+
<?if $(var.Platform)~=x64?>
29+
<Fragment>
30+
<!-- When running in a non-native architecture and user hasn't specified install directory,
31+
install to an x64 subdirectory.
32+
This is only define for x64, since x86 has redirection and no other native architecture can install ARM64 today -->
33+
<SetProperty Action="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" Id="DOTNETHOME" Value="[ProgramFiles64Folder]dotnet\x64\" After="Set_NON_NATIVE_ARCHITECTURE">
34+
NON_NATIVE_ARCHITECTURE AND NOT DOTNETHOME
35+
</SetProperty>
36+
</Fragment>
37+
<?endif?>
38+
</Wix>

src/redist/targets/packaging/windows/clisdk/generatemanifestsmsi.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function RunCandle
6565
-ext WixDependencyExtension.dll `
6666
"$PSScriptRoot\manifests.wxs" `
6767
"$PSScriptRoot\provider.wxs" `
68+
"$PSScriptRoot\dotnethome_x64.wxs" `
6869
$InstallFileswsx
6970

7071
Write-Information "Candle output: $candleOutput"
@@ -91,6 +92,7 @@ function RunLight
9192
-cultures:en-us `
9293
manifests.wixobj `
9394
provider.wixobj `
95+
dotnethome_x64.wixobj `
9496
$InstallFilesWixobj `
9597
-b "$inputDir" `
9698
-b "$PSScriptRoot" `

src/redist/targets/packaging/windows/clisdk/generatemsi.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function RunCandle
7373
-arch "$Architecture" `
7474
-ext WixDependencyExtension.dll `
7575
"$PSScriptRoot\dotnet.wxs" `
76+
"$PSScriptRoot\dotnethome_x64.wxs" `
7677
"$PSScriptRoot\provider.wxs" `
7778
"$PSScriptRoot\registrykeys.wxs" `
7879
$InstallFileswsx
@@ -100,6 +101,7 @@ function RunLight
100101
$lightOutput = .\light.exe -nologo -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension `
101102
-cultures:en-us `
102103
dotnet.wixobj `
104+
dotnethome_x64.wixobj `
103105
provider.wixobj `
104106
registrykeys.wixobj `
105107
$InstallFilesWixobj `

src/redist/targets/packaging/windows/clisdk/generatetemplatesmsi.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function RunCandle
6363
-dDependencyKeyName="$DependencyKeyName" `
6464
-arch "$Architecture" `
6565
-ext WixDependencyExtension.dll `
66+
"$PSScriptRoot\dotnethome_x64.wxs" `
6667
"$PSScriptRoot\templates.wxs" `
6768
"$PSScriptRoot\provider.wxs" `
6869
$InstallFileswsx
@@ -89,6 +90,7 @@ function RunLight
8990

9091
$lightOutput = .\light.exe -nologo -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension `
9192
-cultures:en-us `
93+
dotnethome_x64.wixobj `
9294
templates.wixobj `
9395
provider.wixobj `
9496
$InstallFilesWixobj `

src/redist/targets/packaging/windows/clisdk/manifests.wxs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@
3232
<Directory Id="DOTNETHOME" Name="dotnet"/>
3333
</Directory>
3434
</Directory>
35+
36+
<?if $(var.Platform)~=x64?>
37+
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
38+
<?endif?>
3539
</Fragment>
3640
</Wix>

src/redist/targets/packaging/windows/clisdk/registrykeys.wxs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,47 @@
3434
</RegistryKey>
3535
</Component>
3636
</ComponentGroup>
37+
38+
<!-- Set values for DOTNETHOME if not passed in.
39+
These searches prefer the existing registry key and fallback to probing the default location if registry key isn't present -->
40+
<Property Id="DOTNETHOME_X86_SEARCH">
41+
<DirectorySearch Id="dirDOTNETHOME_X86_search" Path="[ProgramFilesFolder]dotnet" AssignToProperty="yes">
42+
<FileSearch Id="fileDOTNETHOME_X86_search" Name="dotnet.exe" />
43+
</DirectorySearch>
44+
<RegistrySearch Id="regDOTNETHOME_X86_search" Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\x86" Name="InstallLocation" Win64="no" Type="raw" />
45+
</Property>
46+
<Property Id="DOTNETHOME_X64_SEARCH">
47+
<DirectorySearch Id="dirDOTNETHOME_X64_search" Path="[ProgramFiles64Folder]dotnet" AssignToProperty="yes">
48+
<FileSearch Id="fileDOTNETHOME_X64_search" Name="dotnet.exe" />
49+
</DirectorySearch>
50+
<RegistrySearch Id="regDOTNETHOME_X64_search" Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64" Name="InstallLocation" Win64="no" Type="raw" />
51+
</Property>
52+
<Property Id="DOTNETHOME_X64_ALT_SEARCH">
53+
<DirectorySearch Id="dirDOTNETHOME_X64_ALT_search" Path="[ProgramFiles64Folder]dotnet\x64" AssignToProperty="yes">
54+
<FileSearch Id="fileDOTNETHOME_X64_ALT_search" Name="dotnet.exe" />
55+
</DirectorySearch>
56+
<RegistrySearch Id="regDOTNETHOME_X64_ALT_search" Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64" Name="InstallLocation" Win64="no" Type="raw" />
57+
</Property>
58+
<Property Id="DOTNETHOME_ARM64_SEARCH">
59+
<DirectorySearch Id="dirDOTNETHOME_ARM64_search" Path="[ProgramFiles64Folder]dotnet" AssignToProperty="yes">
60+
<FileSearch Id="fileDOTNETHOME_ARM64_search" Name="dotnet.exe" />
61+
</DirectorySearch>
62+
<RegistrySearch Id="regDOTNETHOME_ARM64_search" Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\arm64" Name="InstallLocation" Win64="no" Type="raw" />
63+
</Property>
64+
65+
<!-- Set the DOTNETHOME property if not passed in and we found a path -->
66+
<SetProperty Id="DOTNETHOME_X86" Value="[DOTNETHOME_X86_SEARCH]" Before="CostFinalize">
67+
NOT DOTNETHOME_X86 AND DOTNETHOME_X86_SEARCH
68+
</SetProperty>
69+
<SetProperty Id="DOTNETHOME_X64" Value="[DOTNETHOME_X64_SEARCH]" Before="CostFinalize">
70+
NOT DOTNETHOME_X64 AND DOTNETHOME_X64_SEARCH AND %PROCESSOR_ARCHITECTURE="AMD64"
71+
</SetProperty>
72+
<SetProperty Action="Set_DOTNETHOME_X64_alt" Id="DOTNETHOME_X64" Value="[DOTNETHOME_X64_ALT_SEARCH]" Before="CostFinalize">
73+
NOT DOTNETHOME_X64 AND DOTNETHOME_X64_ALT_SEARCH AND NOT %PROCESSOR_ARCHITECTURE="AMD64"
74+
</SetProperty>
75+
<SetProperty Id="DOTNETHOME_ARM64" Value="[DOTNETHOME_ARM64_SEARCH]" Before="CostFinalize">
76+
NOT DOTNETHOME_ARM64 AND DOTNETHOME_ARM64_SEARCH
77+
</SetProperty>
78+
3779
</Fragment>
3880
</Wix>

src/redist/targets/packaging/windows/clisdk/templates.wxs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@
3232
<Directory Id="DOTNETHOME" Name="dotnet"/>
3333
</Directory>
3434
</Directory>
35+
36+
<?if $(var.Platform)~=x64?>
37+
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
38+
<?endif?>
3539
</Fragment>
3640
</Wix>

0 commit comments

Comments
 (0)