Skip to content

Commit ffecbc5

Browse files
committed
Refactor Set_DOTNETHOME_x64 into a single shared source file
1 parent 74dfcbe commit ffecbc5

9 files changed

Lines changed: 45 additions & 46 deletions

File tree

src/Common/wix/dotnethome_x64.wxs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
<!-- Only defined for x64 as that is the only platform we redirect -->
5+
<?if $(var.Platform)=x64?>
6+
<Fragment>
7+
<Property Id="PROCESSOR_ARCHITECTURE">
8+
<RegistrySearch Id="Search_PROCESSOR_ARCHITECTURE"
9+
Root="HKLM"
10+
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
11+
Name="PROCESSOR_ARCHITECTURE"
12+
Type="raw" />
13+
</Property>
14+
15+
<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE is not AMD64
16+
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
17+
<SetProperty Id="INSTALLING_IN_EMULATION" Value="true" Before="Set_DOTNETHOME_x64">
18+
NOT PROCESSOR_ARCHITECTURE="AMD64"
19+
</SetProperty>
20+
<!-- When running in x64 emulation and user hasn't specified install directory, install to an x64 subdirectory-->
21+
<SetProperty Action="Set_DOTNETHOME_x64" Id="DOTNETHOME" Value="[ProgramFiles64Folder]dotnet\x64\" Before="CostFinalize">
22+
INSTALLING_IN_EMULATION AND NOT DOTNETHOME
23+
</SetProperty>
24+
</Fragment>
25+
<?endif?>
26+
</Wix>

src/Microsoft.DotNet.Build.Tasks.Installers/Microsoft.DotNet.Build.Tasks.Installers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<None Include="build/**/*.*" Pack="true">
2626
<PackagePath>build</PackagePath>
2727
</None>
28+
<None Include="..\Common\wix\dotnethome_x64.wxs" Link="build\wix\product\dotnethome_x64.wxs" PackagePath="%(Link)" Pack="true" />
2829
</ItemGroup>
2930

3031
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">

src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/product/product.wxs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?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. -->
23
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
34

45
<?include "..\variables.wxi" ?>
@@ -56,24 +57,4 @@
5657
<CustomActionRef Id="Set_DOTNETHOME_x64" />
5758
<?endif?>
5859
</Fragment>
59-
60-
<Fragment>
61-
<Property Id="PROCESSOR_ARCHITECTURE">
62-
<RegistrySearch Id="Search_PROCESSOR_ARCHITECTURE"
63-
Root="HKLM"
64-
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
65-
Name="PROCESSOR_ARCHITECTURE"
66-
Type="raw" />
67-
</Property>
68-
69-
<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE is not AMD64
70-
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
71-
<SetProperty Id="INSTALLING_IN_EMULATION" Value="true" Before="Set_DOTNETHOME_x64">
72-
NOT PROCESSOR_ARCHITECTURE="AMD64"
73-
</SetProperty>
74-
<!-- When running in x64 emulation and user hasn't specified install directory, install to an x64 subdirectory-->
75-
<SetProperty Action="Set_DOTNETHOME_x64" Id="DOTNETHOME" Value="[$(var.Program_Files)]dotnet\x64\" Before="CostFinalize">
76-
INSTALLING_IN_EMULATION AND NOT DOTNETHOME
77-
</SetProperty>
78-
</Fragment>
7960
</Wix>

src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<WixExtensions Include="WixUtilExtension.dll" />
109109

110110
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/product.wxs" />
111+
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/dotnethome_x64.wxs" />
111112
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/provider.wxs" />
112113
</ItemGroup>
113114
</Target>

src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public override bool Execute()
167167
List<string> sourceFiles = new();
168168
string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform);
169169
sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath));
170-
sourceFiles.Add(EmbeddedTemplates.Extract("Directories.wxs", msiSourcePath));
170+
sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath));
171171
sourceFiles.Add(EmbeddedTemplates.Extract("ManifestProduct.wxs", msiSourcePath));
172172

173173
string EulaRtfPath = Path.Combine(msiSourcePath, "eula.rtf");

src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
164164
string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform);
165165
sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath));
166166
sourceFiles.Add(EmbeddedTemplates.Extract("Directories.wxs", msiSourcePath));
167+
sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath));
167168
sourceFiles.Add(EmbeddedTemplates.Extract("Product.wxs", msiSourcePath));
168169
sourceFiles.Add(EmbeddedTemplates.Extract("Registry.wxs", msiSourcePath));
169170

src/Microsoft.DotNet.Build.Tasks.Workloads/src/Microsoft.DotNet.Build.Tasks.Workloads.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<EmbeddedResource Include="Misc\*.*" />
5353
<EmbeddedResource Include="MsiTemplate\*.wxs" />
5454
<EmbeddedResource Include="MsiTemplate\*.wxi" />
55+
<EmbeddedResource Include="..\..\Common\wix\dotnethome_x64.wxs" Link="MsiTemplate\dotnethome_x64.wxs" />
5556
<EmbeddedResource Include="SwixTemplate\*.swr" />
5657
<EmbeddedResource Include="SwixTemplate\*.swixproj" />
5758
<EmbeddedResource Include="SwixTemplate\*.vsmanproj" />

src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/Directories.wxs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,4 @@
2121
<CustomActionRef Id="Set_DOTNETHOME_x64" />
2222
<?endif?>
2323
</Fragment>
24-
25-
<Fragment>
26-
<Property Id="PROCESSOR_ARCHITECTURE">
27-
<RegistrySearch Id="Search_PROCESSOR_ARCHITECTURE"
28-
Root="HKLM"
29-
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
30-
Name="PROCESSOR_ARCHITECTURE"
31-
Type="raw" />
32-
</Property>
33-
34-
<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE is not AMD64
35-
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
36-
<SetProperty Id="INSTALLING_IN_EMULATION" Value="true" Before="Set_DOTNETHOME_x64">
37-
NOT PROCESSOR_ARCHITECTURE="AMD64"
38-
</SetProperty>
39-
<!-- When running in x64 emulation and user hasn't specified install directory, install to an x64 subdirectory-->
40-
<SetProperty Action="Set_DOTNETHOME_x64" Id="DOTNETHOME" Value="[$(var.ProgramFilesFolder)]dotnet\x64\" Before="CostFinalize">
41-
INSTALLING_IN_EMULATION AND NOT DOTNETHOME
42-
</SetProperty>
43-
</Fragment>
4424
</Wix>

src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/ManifestProduct.wxs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@
2323
NOT WIX_DOWNGRADE_DETECTED
2424
</Condition>
2525

26-
<DirectoryRef Id="DOTNETHOME">
27-
<Directory Id="ManifestDir" Name="sdk-manifests">
28-
<Directory Id="VersionDir" Name="$(var.SdkFeatureBandVersion)">
29-
<Directory Id="ManifestIdDir" Name="$(var.ManifestId)" />
26+
<Directory Id="TARGETDIR" Name="SourceDir">
27+
<Directory Id="$(var.ProgramFilesFolder)">
28+
<Directory Id="DOTNETHOME" Name="dotnet">
29+
<Directory Id="ManifestDir" Name="sdk-manifests">
30+
<Directory Id="VersionDir" Name="$(var.SdkFeatureBandVersion)">
31+
<Directory Id="ManifestIdDir" Name="$(var.ManifestId)" />
32+
</Directory>
33+
</Directory>
3034
</Directory>
3135
</Directory>
32-
</DirectoryRef>
36+
</Directory>
37+
38+
<?if $(var.Platform) = x64 ?>
39+
<CustomActionRef Id="Set_DOTNETHOME_x64" />
40+
<?endif?>
3341

3442
<MediaTemplate CompressionLevel="high" EmbedCab="yes" />
3543

0 commit comments

Comments
 (0)