Skip to content

Commit 38452c0

Browse files
[release/6.0-rc2] Retarget DOTNETHOME when installing x64 on ARM64 (#36695)
* Retarget DOTNETHOME when installing x64 on ARM64 * Make platform comparison case insenstive * Address feedback * Install x64 registry keys to different path on ARM64 machine Co-authored-by: Eric StJohn <[email protected]>
1 parent 8a1974d commit 38452c0

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed
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/Installers/Windows/SharedFramework/Product.wxs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
</Directory>
3636
</Directory>
3737
</Directory>
38+
39+
<?if $(var.Platform)=x64?>
40+
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
41+
<?endif?>
3842
</Fragment>
3943

4044
<Fragment>
@@ -52,6 +56,10 @@
5256
<ComponentRef Id="C_eula.rtf" />
5357
<ComponentRef Id="C_ProductVersion"/>
5458
<ComponentRef Id="C_ProductInstallDir"/>
59+
<?if $(var.Platform)=x64 ?>
60+
<ComponentRef Id="C_ProductVersion_NonNative" />
61+
<ComponentRef Id="C_ProductInstallDir_NonNative" />
62+
<?endif?>
5563
</ComponentGroup>
5664

5765
<DirectoryRef Id="SharedFolder">
@@ -66,16 +74,41 @@
6674
<?define ProductVersionKey=SOFTWARE\Microsoft\ASP.NET Core\Shared Framework\v$(var.MajorVersion).$(var.MinorVersion)\$(var.PackageVersion)?>
6775

6876
<Component Id="C_ProductVersion">
77+
<?if $(var.Platform)=x64 ?>
78+
<!-- Only install when actually on native architecture -->
79+
<Condition>NOT NON_NATIVE_ARCHITECTURE</Condition>
80+
<?endif?>
6981
<RegistryKey Key="$(var.ProductVersionKey)" Root="HKLM">
7082
<RegistryValue Name="Version" Type="string" Value="$(var.Version)" />
7183
</RegistryKey>
7284
</Component>
7385

7486
<Component Id="C_ProductInstallDir">
87+
<?if $(var.Platform)=x64 ?>
88+
<!-- Only install when actually on native architecture -->
89+
<Condition>NOT NON_NATIVE_ARCHITECTURE</Condition>
90+
<?endif?>
7591
<RegistryKey Key="SOFTWARE\Microsoft\ASP.NET Core\Shared Framework" Root="HKLM">
7692
<RegistryValue Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
7793
</RegistryKey>
7894
</Component>
95+
96+
<?if $(var.Platform)=x64 ?>
97+
<!-- Install keys to a different path when not native architecture -->
98+
<Component Id="C_ProductVersion_NonNative">
99+
<Condition>NON_NATIVE_ARCHITECTURE</Condition>
100+
<RegistryKey Key="$(var.ProductVersionKey)\$(var.Platform)" Root="HKLM">
101+
<RegistryValue Name="Version" Type="string" Value="$(var.Version)" />
102+
</RegistryKey>
103+
</Component>
104+
105+
<Component Id="C_ProductInstallDir_NonNative">
106+
<Condition>NON_NATIVE_ARCHITECTURE</Condition>
107+
<RegistryKey Key="SOFTWARE\Microsoft\ASP.NET Core\Shared Framework\$(var.Platform)" Root="HKLM">
108+
<RegistryValue Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
109+
</RegistryKey>
110+
</Component>
111+
<?endif?>
79112
</DirectoryRef>
80113
</Fragment>
81114
</Wix>

src/Installers/Windows/SharedFramework/SharedFramework.wixproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<ItemGroup>
4747
<Compile Include="DependencyProvider.wxs" />
4848
<Compile Include="Product.wxs" />
49+
<Compile Include="..\Common\dotnethome_x64.wxs" Link="dotnethome_x64.wxs" />
4950
<EmbeddedResource Include="Strings.wxl" />
5051
</ItemGroup>
5152

src/Installers/Windows/TargetingPack/Product.wxs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
<Directory Id="DOTNETHOME" Name="dotnet" />
4040
</Directory>
4141
</Directory>
42+
43+
<?if $(var.Platform)=x64?>
44+
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
45+
<?endif?>
4246
</Fragment>
4347

4448
<Fragment>
@@ -55,6 +59,10 @@
5559
<ComponentGroup Id="CG_ProductInfo">
5660
<ComponentRef Id="C_ProductVersion"/>
5761
<ComponentRef Id="C_ProductInstallDir"/>
62+
<?if $(var.Platform)=x64 ?>
63+
<ComponentRef Id="C_ProductVersion_NonNative"/>
64+
<ComponentRef Id="C_ProductInstallDir_NonNative"/>
65+
<?endif?>
5866
</ComponentGroup>
5967

6068
<DirectoryRef Id="DOTNETHOME">
@@ -65,16 +73,41 @@
6573
<?define ProductVersionKey=SOFTWARE\Microsoft\ASP.NET Core\Targeting Pack\v$(var.MajorVersion).$(var.MinorVersion)\$(var.PackageVersion)?>
6674

6775
<Component Id="C_ProductVersion">
76+
<?if $(var.Platform)=x64 ?>
77+
<!-- Only install when actually on native architecture -->
78+
<Condition>NOT NON_NATIVE_ARCHITECTURE</Condition>
79+
<?endif?>
6880
<RegistryKey Key="$(var.ProductVersionKey)" Root="HKLM">
6981
<RegistryValue Name="Version" Type="string" Value="$(var.Version)" />
7082
</RegistryKey>
7183
</Component>
7284

7385
<Component Id="C_ProductInstallDir">
86+
<?if $(var.Platform)=x64 ?>
87+
<!-- Only install when actually on native architecture -->
88+
<Condition>NOT NON_NATIVE_ARCHITECTURE</Condition>
89+
<?endif?>
7490
<RegistryKey Key="SOFTWARE\Microsoft\ASP.NET Core\Targeting Pack" Root="HKLM">
7591
<RegistryValue Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
7692
</RegistryKey>
7793
</Component>
94+
95+
96+
<?if $(var.Platform)=x64 ?>
97+
<!-- Install keys to a different path when not native architecture -->
98+
<Component Id="C_ProductVersion_NonNative">
99+
<Condition>NON_NATIVE_ARCHITECTURE</Condition>
100+
<RegistryKey Key="$(var.ProductVersionKey)\$(var.Platform)" Root="HKLM">
101+
<RegistryValue Name="Version" Type="string" Value="$(var.Version)" />
102+
</RegistryKey>
103+
</Component>
104+
<Component Id="C_ProductInstallDir_NonNative">
105+
<Condition>NON_NATIVE_ARCHITECTURE</Condition>
106+
<RegistryKey Key="SOFTWARE\Microsoft\ASP.NET Core\Targeting Pack\$(var.Platform)" Root="HKLM">
107+
<RegistryValue Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
108+
</RegistryKey>
109+
</Component>
110+
<?endif?>
78111
</DirectoryRef>
79112
</Fragment>
80113
</Wix>

src/Installers/Windows/TargetingPack/TargetingPack.wixproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<ItemGroup>
4949
<Compile Include="DependencyProvider.wxs" />
5050
<Compile Include="Product.wxs" />
51+
<Compile Include="..\Common\dotnethome_x64.wxs" Link="dotnethome_x64.wxs" />
5152
<EmbeddedResource Include="Strings.wxl" />
5253
</ItemGroup>
5354

0 commit comments

Comments
 (0)