From 4fbe444a1a9794fb9affa5ea7236bef92dcf44b9 Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 9 Sep 2021 11:58:01 -0700 Subject: [PATCH 1/6] Account for target installer arch in mac pkg id generation (#7831) --- .../build/installer.singlerid.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/build/installer.singlerid.targets b/src/Microsoft.DotNet.Build.Tasks.Installers/build/installer.singlerid.targets index a692fecae35..2651a4588fd 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/build/installer.singlerid.targets +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/build/installer.singlerid.targets @@ -399,7 +399,7 @@ RemoveProperties="@(_GlobalPropertiesToRemoveForPublish)" /> <_MacOSVersionComponent Condition="'$(IncludeVersionInMacOSComponentName)' == 'true'">.$(InstallerPackageVersion) - <_MacOSComponentName Condition="'$(_MacOSComponentName)' == ''">com.microsoft.dotnet.$(MacOSComponentNamePackType)$(_MacOSVersionComponent).component.osx.x64 + <_MacOSComponentName Condition="'$(_MacOSComponentName)' == ''">com.microsoft.dotnet.$(MacOSComponentNamePackType)$(_MacOSVersionComponent).component.osx.$(InstallerTargetArchitecture) <_MacOSSharedInstallDir>/usr/local/share/dotnet <_pkgArgs> From 225f864e03d9d012a7b7987feb9c1600b9931a67 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Fri, 3 Sep 2021 16:00:25 -0700 Subject: [PATCH 2/6] 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 @@ + + + + From a0aa5f36cbf2d3a8570d350711102d7fb6aaefb9 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Wed, 8 Sep 2021 15:45:09 -0700 Subject: [PATCH 3/6] Remove Bundle override of DOTNETHOME (#7855) The bundle was passing in a hardcoded DOTNETHOME value unconditionally to MSIs in the chain. This value doesn't have the redirection we're adding to the MSI. We can't add that redirection in the bundle, since Burn doesn't have conditional variables. It can only set variables as a result of a search to either the value of the search (if successful) or 1/0. --- .../build/wix/bundle/bundle.wxs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/bundle/bundle.wxs b/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/bundle/bundle.wxs index cd908f06756..7f968434f10 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/bundle/bundle.wxs +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix/bundle/bundle.wxs @@ -43,9 +43,7 @@ - - - + @@ -54,9 +52,7 @@ - - - + From aa0a3d3b95ea3744a9ea643217766b7b10e8bfbe Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Tue, 7 Sep 2021 12:31:07 -0700 Subject: [PATCH 4/6] Ensure workloads can find embedded dotnethome_x64.wxs (#7845) --- .../src/EmbeddedTemplates.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/EmbeddedTemplates.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/EmbeddedTemplates.cs index 1ad0d3a7662..2fbabf1bcae 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/EmbeddedTemplates.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/EmbeddedTemplates.cs @@ -64,6 +64,7 @@ static EmbeddedTemplates() { { "DependencyProvider.wxs", $"{s_namespace}.MsiTemplate.DependencyProvider.wxs" }, { "Directories.wxs", $"{s_namespace}.MsiTemplate.Directories.wxs" }, + { "dotnethome_x64.wxs", $"{s_namespace}.MsiTemplate.dotnethome_x64.wxs" }, { "ManifestProduct.wxs", $"{s_namespace}.MsiTemplate.ManifestProduct.wxs" }, { "Product.wxs", $"{s_namespace}.MsiTemplate.Product.wxs" }, { "Registry.wxs", $"{s_namespace}.MsiTemplate.Registry.wxs" }, From fe23bc12e191c8390d445f1f441ddd3560f341ed Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 16 Sep 2021 15:49:38 -0700 Subject: [PATCH 5/6] Adding x64 emulation support for pkg installers (#7893) * Adding x64 emulation support for pkg installers * PR feedback * PR feedback --- .../src/GenerateMacOSDistributionFile.cs | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs b/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs index 4a2242b80bd..4d988fd2d75 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs @@ -30,6 +30,8 @@ public class GenerateMacOSDistributionFile : BuildTask [Required] public string DestinationFile { get; set; } + public string Alternativex64InstallPath { get; set; } + public override bool Execute() { try @@ -38,7 +40,16 @@ public override bool Execute() var titleElement = new XElement("title", $"{ProductBrandName} ({TargetArchitecture})"); - var choiceLineElements = BundledPackages.Select(component => new XElement("line", new XAttribute("choice", component.GetMetadata("FileNameWithExtension")))); + var archScriptContent = @""; + var scriptElement = new XElement("script", new XText(archScriptContent)); var choiceElements = BundledPackages .Select(component => new XElement("choice", @@ -48,6 +59,23 @@ public override bool Execute() new XAttribute("description", component.GetMetadata("Description")), new XElement("pkg-ref", new XAttribute("id", component.GetMetadata("FileNameWithExtension"))))); + if (TargetArchitecture == "x64") + { + Alternativex64InstallPath ??= "/usr/local/share/dotnet/x64"; + + choiceElements = + choiceElements.Select(c => new XElement(c) + .WithAttribute("selected", "IsX64Machine()")) + .Concat( + choiceElements.Select(c => new XElement(c) + .WithAttribute("id", c.Attribute("id").Value + ".alternate") + .WithAttribute("selected", "!IsX64Machine()") + .WithAttribute("customLocation", Alternativex64InstallPath))); + } + + var choiceLineElements = choiceElements + .Select(c => new XElement("line", new XAttribute("choice", c.Attribute("id").Value))); + var pkgRefElements = BundledPackages .Select(component => new XElement("pkg-ref", new XAttribute("id", component.GetMetadata("FileNameWithExtension")), @@ -78,6 +106,7 @@ public override bool Execute() document.Root.Add(new XElement("choices-outline", choiceLineElements)); document.Root.Add(choiceElements); document.Root.Add(pkgRefElements); + document.Root.Add(scriptElement); using XmlWriter writer = XmlWriter.Create(File.OpenWrite(DestinationFile)); document.WriteTo(writer); } @@ -89,4 +118,13 @@ public override bool Execute() return true; } } + + static class XElementExtensions + { + public static XElement WithAttribute(this XElement element, XName attribute, object value) + { + element.SetAttributeValue(attribute, value); + return element; + } + } } From 3abbdb89f63d146a52c999724d409675f6fdcaf2 Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Fri, 17 Sep 2021 16:07:36 -0700 Subject: [PATCH 6/6] Update mac x64 installer script arch detection (#7913) * Update mac x64 installer script arch detection * Add comments to x64 machine detection script --- .../src/GenerateMacOSDistributionFile.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs b/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs index 4d988fd2d75..d471bee08dd 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs @@ -42,11 +42,19 @@ public override bool Execute() var archScriptContent = @""; var scriptElement = new XElement("script", new XText(archScriptContent));