From 0ec8dbacaefa7ccdb4bc96e120e07dc60c6eda98 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Fri, 3 Sep 2021 16:00:25 -0700 Subject: [PATCH] Adding detection and retargeting of DOTNETHOME (#7785) * Adding detection and retargeting of DOTNETHOME When x64 is installed on non-x64 machine, place in an x64 subdirectory. * Remove test value of dotnet folder * Fix ProgramFilesFolder preprocessor variable usage * Refactor Set_DOTNETHOME_x64 into a single shared source file * Add CA ID for INSTALLING_IN_EMULATION. * Define Platform consistently * Move workload registration to platform specific * Refactor INSTALLING_IN_EMULATION property Don't need to use a registry search since environment of the MSIServer process can be read (TBD pending reccomendation from MSI team). Also make property work for any architecture, in case we wish to use it more generically (EG: to condition PATH entry in host installer). * Make platform comparison case insensitive * Respond to feedback --- src/Common/wix/dotnethome_x64.wxs | 38 +++++++++++++++++++ ...osoft.DotNet.Build.Tasks.Installers.csproj | 1 + .../build/wix/product/product.wxs | 6 ++- .../build/wix/wix.targets | 1 + .../src/GenerateManifestMsi.cs | 1 + .../src/GenerateMsiBase.cs | 1 + ...rosoft.DotNet.Build.Tasks.Workloads.csproj | 1 + .../src/MsiTemplate/Directories.wxs | 4 ++ .../src/MsiTemplate/ManifestProduct.wxs | 4 ++ 9 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/Common/wix/dotnethome_x64.wxs diff --git a/src/Common/wix/dotnethome_x64.wxs b/src/Common/wix/dotnethome_x64.wxs new file mode 100644 index 00000000000..5e30f98719d --- /dev/null +++ b/src/Common/wix/dotnethome_x64.wxs @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + ? + + + + + + NOT %PROCESSOR_ARCHITECTURE="$(var.InstallerArchitecture)" + + + + + + + + NON_NATIVE_ARCHITECTURE AND NOT DOTNETHOME + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/Microsoft.DotNet.Build.Tasks.Installers.csproj b/src/Microsoft.DotNet.Build.Tasks.Installers/Microsoft.DotNet.Build.Tasks.Installers.csproj index 17fa172fe3f..45eb895e1dc 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/Microsoft.DotNet.Build.Tasks.Installers.csproj +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/Microsoft.DotNet.Build.Tasks.Installers.csproj @@ -25,6 +25,7 @@ build + diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/product/product.wxs b/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/product/product.wxs index 1bf18ed9e2d..28a564cd295 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/product/product.wxs +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/product/product.wxs @@ -1,4 +1,5 @@ + @@ -51,6 +52,9 @@ - + + + + diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets b/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets index 7890004666d..86ee8067fe3 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/wix.targets @@ -108,6 +108,7 @@ + diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs index a9ab8650c44..d5178ef9bd5 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs @@ -167,6 +167,7 @@ public override bool Execute() List sourceFiles = new(); string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform); sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath)); + sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath)); sourceFiles.Add(EmbeddedTemplates.Extract("ManifestProduct.wxs", msiSourcePath)); string EulaRtfPath = Path.Combine(msiSourcePath, "eula.rtf"); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs index 11b7560fa4b..c9a4bf14510 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs @@ -176,6 +176,7 @@ protected IEnumerable 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)); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Microsoft.DotNet.Build.Tasks.Workloads.csproj b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Microsoft.DotNet.Build.Tasks.Workloads.csproj index e44ad1cc54a..19cf67b52d7 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Microsoft.DotNet.Build.Tasks.Workloads.csproj +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Microsoft.DotNet.Build.Tasks.Workloads.csproj @@ -52,6 +52,7 @@ + diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/Directories.wxs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/Directories.wxs index 709bbb08563..e40ac5bb203 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/Directories.wxs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/Directories.wxs @@ -16,5 +16,9 @@ + + + + diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/ManifestProduct.wxs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/ManifestProduct.wxs index 128fe2200bb..7a78f090232 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/ManifestProduct.wxs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/ManifestProduct.wxs @@ -35,6 +35,10 @@ + + + +