From acd12fae2b2bd4af6a1b29cb5574ea7e4513b870 Mon Sep 17 00:00:00 2001 From: Jacob Affinito Date: Fri, 10 May 2024 14:07:55 -0700 Subject: [PATCH] fix: Upgrade Wix to v5 to fix an issue with non-elevated installs. (#2471) --- .github/dependabot.yml | 8 + .../ArtifactBuilder/Artifacts/MsiInstaller.cs | 18 +- .../ArtifactBuilder/ParsedProductWxsTypes.cs | 65 +- .../MsiInstaller/Installer/Installer.wixproj | 66 +- .../Installer/LicenseKeyDialog.wxs | 23 +- src/Agent/MsiInstaller/Installer/Product.wxs | 711 +++++++++--------- src/Agent/MsiInstaller/Installer/WizardUI.wxs | 21 +- .../InstallerActions/CustomAction.config | 5 +- .../InstallerActions/CustomActions.cs | 2 +- .../InstallerActions/InstallerActions.csproj | 66 +- .../Properties/AssemblyInfo.cs | 15 - src/Agent/MsiInstaller/MsiInstaller.sln | 4 +- 12 files changed, 449 insertions(+), 555 deletions(-) delete mode 100644 src/Agent/MsiInstaller/InstallerActions/Properties/AssemblyInfo.cs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 54ea39316f..dc5c7c9def 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -44,3 +44,11 @@ updates: nuget: patterns: - "*" + - package-ecosystem: nuget + directory: /src/Agent/MsiInstaller + schedule: + interval: weekly + groups: + nuget: + patterns: + - "*" diff --git a/build/ArtifactBuilder/Artifacts/MsiInstaller.cs b/build/ArtifactBuilder/Artifacts/MsiInstaller.cs index 08411f7294..724fd69cf6 100644 --- a/build/ArtifactBuilder/Artifacts/MsiInstaller.cs +++ b/build/ArtifactBuilder/Artifacts/MsiInstaller.cs @@ -229,7 +229,7 @@ private void ValidateWixIisRegistryDefinitions(WixFragmentComponentGroup framewo foreach (var value in _frameworkIISRegistryValues) { - if (!component.RegistryValue.MultiStringValue.Contains(value)) + if (!component.RegistryValue.MultiStringValue.Any(msv => msv.Value == value)) { throw new PackagingException($@"Product.wxs Framework registryvalue {component.RegistryValue.Name}\{component.RegistryValue.Name} missing {value}"); } @@ -251,7 +251,7 @@ private void ValidateWixIisRegistryDefinitions(WixFragmentComponentGroup framewo foreach (var value in _coreIISRegistryValues) { - if (!component.RegistryValue.MultiStringValue.Contains(value)) + if (!component.RegistryValue.MultiStringValue.Any(msv => msv.Value == value)) { throw new PackagingException($@"Product.wxs Core registryvalue {component.RegistryValue.Name}\{component.RegistryValue.Name} missing {value}"); } @@ -313,13 +313,25 @@ private void ValidateContent() return; } + // Wix v4+ admin install places files into proper subdirectories instead of a single directory + // Combining the new directories results in the same structure from Wix v3 for less changes + var commAppRoot = Path.Join(unpackedLocation, "CommApp", "New Relic", ".NET Agent"); + var pFilesRootx86 = Path.Join(unpackedLocation, "PFiles", "New Relic", ".NET Agent"); + var pFilesRootx64 = Path.Join(unpackedLocation, "PFiles64", "New Relic", ".NET Agent"); var installedFilesRoot = Path.Join(unpackedLocation, "New Relic", ".NET Agent"); + FileHelpers.CopyAll(commAppRoot, installedFilesRoot); + FileHelpers.CopyAll(pFilesRootx86, installedFilesRoot); // needed for both x86 and x64 + if (Platform == "x64") + { + FileHelpers.CopyAll(pFilesRootx64, installedFilesRoot); + } + var expectedComponents = GetExpectedComponents(installedFilesRoot); var unpackedComponents = ValidationHelpers.GetUnpackedComponents(installedFilesRoot); - ValidationHelpers.ValidateComponents(expectedComponents, unpackedComponents, "msi"); + ValidationHelpers.ValidateComponents(expectedComponents, unpackedComponents, Platform + " msi"); FileHelpers.DeleteDirectories(unpackedLocation); } diff --git a/build/ArtifactBuilder/ParsedProductWxsTypes.cs b/build/ArtifactBuilder/ParsedProductWxsTypes.cs index 983bbee18c..5236f749d9 100644 --- a/build/ArtifactBuilder/ParsedProductWxsTypes.cs +++ b/build/ArtifactBuilder/ParsedProductWxsTypes.cs @@ -7,108 +7,97 @@ namespace ArtifactBuilder { // This code was auto-generated by visual studio and then edited to remove all of the generated // classes that were not needed for our testing purposes. - // NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0. - /// + [Serializable] [DesignerCategory("code")] - [XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")] - [XmlRoot(Namespace = "http://schemas.microsoft.com/wix/2006/wi", IsNullable = false)] + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] + [XmlRoot(Namespace = "http://wixtoolset.org/schemas/v4/wxs", IsNullable = false)] public class Wix { - /// + public WixFragment Fragment { get; set; } } - /// [Serializable] [DesignerCategory("code")] - [XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")] + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] public class WixFragment { - /// [XmlElement("ComponentGroup", typeof(WixFragmentComponentGroup))] public object[] Items { get; set; } } - /// [Serializable] [DesignerCategory("code")] - [XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")] + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] public class WixFragmentComponentGroup { - /// [XmlElement("Component")] public WixFragmentComponentGroupComponent[] Component { get; set; } - /// [XmlAttribute] public string Id { get; set; } - /// [XmlAttribute] public string Directory { get; set; } } - /// [Serializable] [DesignerCategory("code")] - [XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")] + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] public class WixFragmentComponentGroupComponent { - /// public WixFragmentComponentGroupComponentFile File { get; set; } - /// public WixFragmentComponentGroupComponentRegistryValue RegistryValue { get; set; } } - /// [Serializable] [DesignerCategory("code")] - [XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")] - public class WixFragmentComponentGroupComponentFile + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] + public class WixFragmentComponentGroupComponentRegistryValue { - /// [XmlAttribute] - public string Id { get; set; } + public string Root { get; set; } - /// [XmlAttribute] public string Name { get; set; } - /// [XmlAttribute] public string KeyPath { get; set; } - /// [XmlAttribute] - public string Source { get; set; } + public string Key { get; set; } + + [XmlElement("MultiStringValue")] + public List MultiStringValue { get; set; } } - /// [Serializable] [DesignerCategory("code")] - [XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")] - public class WixFragmentComponentGroupComponentRegistryValue + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] + public class WixFragmentComponentGroupComponentRegistryValueMultiStringValue + { + [XmlAttribute()] + public string Value { get; set; } + } + + [Serializable] + [DesignerCategory("code")] + [XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")] + public class WixFragmentComponentGroupComponentFile { - /// [XmlAttribute] - public string Root { get; set; } + public string Id { get; set; } - /// [XmlAttribute] public string Name { get; set; } - /// [XmlAttribute] public string KeyPath { get; set; } - /// [XmlAttribute] - public string Key { get; set; } - - [XmlElement(ElementName = "MultiStringValue", Namespace = "http://schemas.microsoft.com/wix/2006/wi")] - public List MultiStringValue { get; set; } + public string Source { get; set; } } } diff --git a/src/Agent/MsiInstaller/Installer/Installer.wixproj b/src/Agent/MsiInstaller/Installer/Installer.wixproj index 6f394bbd67..113c76d8b3 100644 --- a/src/Agent/MsiInstaller/Installer/Installer.wixproj +++ b/src/Agent/MsiInstaller/Installer/Installer.wixproj @@ -1,33 +1,11 @@ - - + - Debug - x86 - 3.6 - b5c13b8f-279b-455b-ace5-864ca37ceb08 - 2.0 Installer - Package $(SolutionDir)..\..\_build\$(Platform)-$(Configuration)\$(OutputName)\ $(SolutionDir)..\..\_build\$(Platform)-$(Configuration)\$(OutputName)\ - $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets - $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + full - - Debug - - - Debug - - - - - - - - - - + InstallerActions @@ -38,33 +16,21 @@ INSTALLFOLDER + - - $(WixExtDir)\WixNetFxExtension.dll - WixNetFxExtension - - - $(WixExtDir)\WixIIsExtension.dll - WixIIsExtension - - - $(WixExtDir)\WixUIExtension.dll - WixUIExtension - - - $(WixExtDir)\WixUtilExtension.dll - WixUtilExtension - + + + + - - + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKLocation('Windows', '10.0'))bin $(WindowsSdkPathBin)\10.0.19041.0 $(WindowsSdkPath)\x64\signtool.exe - - + + @@ -73,8 +39,6 @@ - - @@ -82,12 +46,10 @@ - - - + ]]> - + \ No newline at end of file diff --git a/src/Agent/MsiInstaller/Installer/LicenseKeyDialog.wxs b/src/Agent/MsiInstaller/Installer/LicenseKeyDialog.wxs index 8e048ccc43..1b9b1181c1 100644 --- a/src/Agent/MsiInstaller/Installer/LicenseKeyDialog.wxs +++ b/src/Agent/MsiInstaller/Installer/LicenseKeyDialog.wxs @@ -1,32 +1,29 @@ - - - + - - - + - - + + - - + + - 1 + - " "]]> + - 1 + diff --git a/src/Agent/MsiInstaller/Installer/Product.wxs b/src/Agent/MsiInstaller/Installer/Product.wxs index 33eb6f2cee..3a85254ec7 100644 --- a/src/Agent/MsiInstaller/Installer/Product.wxs +++ b/src/Agent/MsiInstaller/Installer/Product.wxs @@ -1,24 +1,16 @@ - - + - - - - + + - - - - + + @@ -34,27 +26,25 @@ SPDX-License-Identifier: Apache-2.0 - - + + - - + + - - = 600)]]> - - - - - - - - - + + + + + + + + + - + @@ -85,112 +75,107 @@ SPDX-License-Identifier: Apache-2.0 - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + + - - - - + + + + - - - - - - + + + + + + - + - - + + - + - - - + - WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed + - + - - + + - - + + - - + - - + + - + - - - + - + - - - - - - - - + + + + + + + + @@ -199,128 +184,60 @@ SPDX-License-Identifier: Apache-2.0 - NOT Installed - NOT Installed - Installed - + + + - Installed - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + + + + - - - - - + + + + + - + - + - + - + - - + + - - - - - + + + + + @@ -330,408 +247,408 @@ SPDX-License-Identifier: Apache-2.0 - - - - - + + + + + - - - - - + + + + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -741,7 +658,7 @@ SPDX-License-Identifier: Apache-2.0 - + @@ -777,12 +694,12 @@ SPDX-License-Identifier: Apache-2.0 - + - - - + + + @@ -795,11 +712,11 @@ SPDX-License-Identifier: Apache-2.0 - + - - + + @@ -807,14 +724,14 @@ SPDX-License-Identifier: Apache-2.0 - + - - + + - + - + @@ -822,19 +739,19 @@ SPDX-License-Identifier: Apache-2.0 - - + + - - + + - - + + @@ -849,38 +766,38 @@ SPDX-License-Identifier: Apache-2.0 --> - - + + - - + + - - + + - + - COR_ENABLE_PROFILING=1 - COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41} - NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER] + + + - COR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll + - + - COR_ENABLE_PROFILING=1 - COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41} - NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER] + + + - COR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll + @@ -889,23 +806,23 @@ SPDX-License-Identifier: Apache-2.0 - CORECLR_ENABLE_PROFILING=1 - CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} - CORECLR_NEWRELIC_HOME=[NETAGENTCOMMONFOLDER] - NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER] + + + + - CORECLR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll + - CORECLR_ENABLE_PROFILING=1 - CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} - CORECLR_NEWRELIC_HOME=[NETAGENTCOMMONFOLDER] - NEWRELIC_INSTALL_PATH=[NETAGENTFOLDER] + + + + - CORECLR_PROFILER_PATH_32=[NETAGENT32FOLDER]NewRelic.Profiler.dll + @@ -921,10 +838,10 @@ SPDX-License-Identifier: Apache-2.0 - + - + @@ -933,16 +850,16 @@ SPDX-License-Identifier: Apache-2.0 - + - + - + - + @@ -950,11 +867,77 @@ SPDX-License-Identifier: Apache-2.0 - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Agent/MsiInstaller/Installer/WizardUI.wxs b/src/Agent/MsiInstaller/Installer/WizardUI.wxs index ae6cfb68a3..648d15addc 100644 --- a/src/Agent/MsiInstaller/Installer/WizardUI.wxs +++ b/src/Agent/MsiInstaller/Installer/WizardUI.wxs @@ -1,26 +1,25 @@ - - - + - - + + - + - 1 + - PREVLICENSEKEYFOUND AND LicenseAccepted = "1" + - NOT PREVLICENSEKEYFOUND AND LicenseAccepted = "1" + - NOT Installed AND NOT PREVLICENSEKEYFOUND + - NOT Installed AND PREVLICENSEKEYFOUND + diff --git a/src/Agent/MsiInstaller/InstallerActions/CustomAction.config b/src/Agent/MsiInstaller/InstallerActions/CustomAction.config index a3f44bbbef..81a9d0932f 100644 --- a/src/Agent/MsiInstaller/InstallerActions/CustomAction.config +++ b/src/Agent/MsiInstaller/InstallerActions/CustomAction.config @@ -1,7 +1,10 @@  + - diff --git a/src/Agent/MsiInstaller/InstallerActions/CustomActions.cs b/src/Agent/MsiInstaller/InstallerActions/CustomActions.cs index f87bf8d789..86bcecd30b 100644 --- a/src/Agent/MsiInstaller/InstallerActions/CustomActions.cs +++ b/src/Agent/MsiInstaller/InstallerActions/CustomActions.cs @@ -7,8 +7,8 @@ using System.Text; using System.Xml; using System.Xml.XPath; -using Microsoft.Deployment.WindowsInstaller; using Microsoft.Win32; +using WixToolset.Dtf.WindowsInstaller; namespace InstallerActions { diff --git a/src/Agent/MsiInstaller/InstallerActions/InstallerActions.csproj b/src/Agent/MsiInstaller/InstallerActions/InstallerActions.csproj index 211c2e1730..4a6a9ceadc 100644 --- a/src/Agent/MsiInstaller/InstallerActions/InstallerActions.csproj +++ b/src/Agent/MsiInstaller/InstallerActions/InstallerActions.csproj @@ -1,69 +1,25 @@ - - - + + - Debug - x86 - 8.0.30703 - 2.0 + net462 {E8C424D3-4493-4FE6-89B1-650A589C4209} - Library - Properties InstallerActions InstallerActions - v3.5 - 512 - $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.CA.targets $(SolutionDir)..\..\_build\$(Platform)-$(Configuration)\$(AssemblyName) $(SolutionDir)..\..\_build\$(Platform)-$(Configuration)\$(AssemblyName) - - 267d8a59 - - - true - full - false - DEBUG;TRACE - prompt - 4 - x86 - - - pdbonly - true - TRACE - prompt - 4 - x86 - - - true - DEBUG;TRACE - full - x64 - prompt - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'FullAgent.sln'))\build\Common.ruleset - true - - - TRACE - true - pdbonly - x64 - prompt $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'FullAgent.sln'))\build\Common.ruleset true + x64;x86 + - - - + + - - - + + + - - + diff --git a/src/Agent/MsiInstaller/InstallerActions/Properties/AssemblyInfo.cs b/src/Agent/MsiInstaller/InstallerActions/Properties/AssemblyInfo.cs deleted file mode 100644 index 3fff0deeef..0000000000 --- a/src/Agent/MsiInstaller/InstallerActions/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -using System.Reflection; - -[assembly: AssemblyTitle("InstallerActions")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("InstallerActions")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Agent/MsiInstaller/MsiInstaller.sln b/src/Agent/MsiInstaller/MsiInstaller.sln index 0a54f0eee1..da8a055157 100644 --- a/src/Agent/MsiInstaller/MsiInstaller.sln +++ b/src/Agent/MsiInstaller/MsiInstaller.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33403.182 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "Installer\Installer.wixproj", "{B5C13B8F-279B-455B-ACE5-864CA37CEB08}" +Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Installer", "Installer\Installer.wixproj", "{B5C13B8F-279B-455B-ACE5-864CA37CEB08}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallerActions", "InstallerActions\InstallerActions.csproj", "{E8C424D3-4493-4FE6-89B1-650A589C4209}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstallerActions", "InstallerActions\InstallerActions.csproj", "{E8C424D3-4493-4FE6-89B1-650A589C4209}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution