Skip to content
Merged
Prev Previous commit
Next Next commit
Refactor Set_DOTNETHOME_x64 into a single shared source file
  • Loading branch information
ericstj committed Aug 25, 2021
commit ffecbc504e64db9f2eb260341cb2db4b033f8779
26 changes: 26 additions & 0 deletions src/Common/wix/dotnethome_x64.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Only defined for x64 as that is the only platform we redirect -->
<?if $(var.Platform)=x64?>
<Fragment>
<Property Id="PROCESSOR_ARCHITECTURE">
<RegistrySearch Id="Search_PROCESSOR_ARCHITECTURE"
Root="HKLM"
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
Name="PROCESSOR_ARCHITECTURE"
Type="raw" />
</Property>

<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE is not AMD64
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<SetProperty Id="INSTALLING_IN_EMULATION" Value="true" Before="Set_DOTNETHOME_x64">
NOT PROCESSOR_ARCHITECTURE="AMD64"
</SetProperty>
<!-- When running in x64 emulation and user hasn't specified install directory, install to an x64 subdirectory-->
<SetProperty Action="Set_DOTNETHOME_x64" Id="DOTNETHOME" Value="[ProgramFiles64Folder]dotnet\x64\" Before="CostFinalize">
INSTALLING_IN_EMULATION AND NOT DOTNETHOME
</SetProperty>
</Fragment>
<?endif?>
</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<None Include="build/**/*.*" Pack="true">
<PackagePath>build</PackagePath>
</None>
<None Include="..\Common\wix\dotnethome_x64.wxs" Link="build\wix\product\dotnethome_x64.wxs" PackagePath="%(Link)" Pack="true" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<?include "..\variables.wxi" ?>
Expand Down Expand Up @@ -56,24 +57,4 @@
<CustomActionRef Id="Set_DOTNETHOME_x64" />
<?endif?>
</Fragment>

<Fragment>
<Property Id="PROCESSOR_ARCHITECTURE">
<RegistrySearch Id="Search_PROCESSOR_ARCHITECTURE"
Root="HKLM"
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
Name="PROCESSOR_ARCHITECTURE"
Type="raw" />
</Property>

<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE is not AMD64
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<SetProperty Id="INSTALLING_IN_EMULATION" Value="true" Before="Set_DOTNETHOME_x64">
NOT PROCESSOR_ARCHITECTURE="AMD64"
</SetProperty>
<!-- When running in x64 emulation and user hasn't specified install directory, install to an x64 subdirectory-->
<SetProperty Action="Set_DOTNETHOME_x64" Id="DOTNETHOME" Value="[$(var.Program_Files)]dotnet\x64\" Before="CostFinalize">
INSTALLING_IN_EMULATION AND NOT DOTNETHOME
</SetProperty>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<WixExtensions Include="WixUtilExtension.dll" />

<WixSrcFile Include="$(MSBuildThisFileDirectory)product/product.wxs" />
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/dotnethome_x64.wxs" />
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/provider.wxs" />
</ItemGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public override bool Execute()
List<string> sourceFiles = new();
string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform);
sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Directories.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("ManifestProduct.wxs", msiSourcePath));

string EulaRtfPath = Path.Combine(msiSourcePath, "eula.rtf");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform);
sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Directories.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Product.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Registry.wxs", msiSourcePath));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<EmbeddedResource Include="Misc\*.*" />
<EmbeddedResource Include="MsiTemplate\*.wxs" />
<EmbeddedResource Include="MsiTemplate\*.wxi" />
<EmbeddedResource Include="..\..\Common\wix\dotnethome_x64.wxs" Link="MsiTemplate\dotnethome_x64.wxs" />
<EmbeddedResource Include="SwixTemplate\*.swr" />
<EmbeddedResource Include="SwixTemplate\*.swixproj" />
<EmbeddedResource Include="SwixTemplate\*.vsmanproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,4 @@
<CustomActionRef Id="Set_DOTNETHOME_x64" />
<?endif?>
</Fragment>

<Fragment>
<Property Id="PROCESSOR_ARCHITECTURE">
<RegistrySearch Id="Search_PROCESSOR_ARCHITECTURE"
Root="HKLM"
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
Name="PROCESSOR_ARCHITECTURE"
Type="raw" />
</Property>

<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE is not AMD64
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<SetProperty Id="INSTALLING_IN_EMULATION" Value="true" Before="Set_DOTNETHOME_x64">
NOT PROCESSOR_ARCHITECTURE="AMD64"
</SetProperty>
<!-- When running in x64 emulation and user hasn't specified install directory, install to an x64 subdirectory-->
<SetProperty Action="Set_DOTNETHOME_x64" Id="DOTNETHOME" Value="[$(var.ProgramFilesFolder)]dotnet\x64\" Before="CostFinalize">
INSTALLING_IN_EMULATION AND NOT DOTNETHOME
</SetProperty>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@
NOT WIX_DOWNGRADE_DETECTED
</Condition>

<DirectoryRef Id="DOTNETHOME">
<Directory Id="ManifestDir" Name="sdk-manifests">
<Directory Id="VersionDir" Name="$(var.SdkFeatureBandVersion)">
<Directory Id="ManifestIdDir" Name="$(var.ManifestId)" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.ProgramFilesFolder)">
<Directory Id="DOTNETHOME" Name="dotnet">
<Directory Id="ManifestDir" Name="sdk-manifests">
<Directory Id="VersionDir" Name="$(var.SdkFeatureBandVersion)">
<Directory Id="ManifestIdDir" Name="$(var.ManifestId)" />
</Directory>
</Directory>
</Directory>
</Directory>
</DirectoryRef>
</Directory>

<?if $(var.Platform) = x64 ?>
<CustomActionRef Id="Set_DOTNETHOME_x64" />
<?endif?>

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

Expand Down