Skip to content

Commit acd12fa

Browse files
authored
fix: Upgrade Wix to v5 to fix an issue with non-elevated installs. (#2471)
1 parent e66bf2c commit acd12fa

File tree

12 files changed

+449
-555
lines changed

12 files changed

+449
-555
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,11 @@ updates:
4444
nuget:
4545
patterns:
4646
- "*"
47+
- package-ecosystem: nuget
48+
directory: /src/Agent/MsiInstaller
49+
schedule:
50+
interval: weekly
51+
groups:
52+
nuget:
53+
patterns:
54+
- "*"

build/ArtifactBuilder/Artifacts/MsiInstaller.cs

+15-3
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private void ValidateWixIisRegistryDefinitions(WixFragmentComponentGroup framewo
229229

230230
foreach (var value in _frameworkIISRegistryValues)
231231
{
232-
if (!component.RegistryValue.MultiStringValue.Contains(value))
232+
if (!component.RegistryValue.MultiStringValue.Any(msv => msv.Value == value))
233233
{
234234
throw new PackagingException($@"Product.wxs Framework registryvalue {component.RegistryValue.Name}\{component.RegistryValue.Name} missing {value}");
235235
}
@@ -251,7 +251,7 @@ private void ValidateWixIisRegistryDefinitions(WixFragmentComponentGroup framewo
251251

252252
foreach (var value in _coreIISRegistryValues)
253253
{
254-
if (!component.RegistryValue.MultiStringValue.Contains(value))
254+
if (!component.RegistryValue.MultiStringValue.Any(msv => msv.Value == value))
255255
{
256256
throw new PackagingException($@"Product.wxs Core registryvalue {component.RegistryValue.Name}\{component.RegistryValue.Name} missing {value}");
257257
}
@@ -313,13 +313,25 @@ private void ValidateContent()
313313
return;
314314
}
315315

316+
// Wix v4+ admin install places files into proper subdirectories instead of a single directory
317+
// Combining the new directories results in the same structure from Wix v3 for less changes
318+
var commAppRoot = Path.Join(unpackedLocation, "CommApp", "New Relic", ".NET Agent");
319+
var pFilesRootx86 = Path.Join(unpackedLocation, "PFiles", "New Relic", ".NET Agent");
320+
var pFilesRootx64 = Path.Join(unpackedLocation, "PFiles64", "New Relic", ".NET Agent");
316321
var installedFilesRoot = Path.Join(unpackedLocation, "New Relic", ".NET Agent");
317322

323+
FileHelpers.CopyAll(commAppRoot, installedFilesRoot);
324+
FileHelpers.CopyAll(pFilesRootx86, installedFilesRoot); // needed for both x86 and x64
325+
if (Platform == "x64")
326+
{
327+
FileHelpers.CopyAll(pFilesRootx64, installedFilesRoot);
328+
}
329+
318330
var expectedComponents = GetExpectedComponents(installedFilesRoot);
319331

320332
var unpackedComponents = ValidationHelpers.GetUnpackedComponents(installedFilesRoot);
321333

322-
ValidationHelpers.ValidateComponents(expectedComponents, unpackedComponents, "msi");
334+
ValidationHelpers.ValidateComponents(expectedComponents, unpackedComponents, Platform + " msi");
323335

324336
FileHelpers.DeleteDirectories(unpackedLocation);
325337
}

build/ArtifactBuilder/ParsedProductWxsTypes.cs

+27-38
Original file line numberDiff line numberDiff line change
@@ -7,108 +7,97 @@ namespace ArtifactBuilder
77
{
88
// This code was auto-generated by visual studio and then edited to remove all of the generated
99
// classes that were not needed for our testing purposes.
10-
1110
// NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
12-
/// <remarks />
11+
1312
[Serializable]
1413
[DesignerCategory("code")]
15-
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
16-
[XmlRoot(Namespace = "http://schemas.microsoft.com/wix/2006/wi", IsNullable = false)]
14+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
15+
[XmlRoot(Namespace = "http://wixtoolset.org/schemas/v4/wxs", IsNullable = false)]
1716
public class Wix
1817
{
19-
/// <remarks />
18+
2019
public WixFragment Fragment { get; set; }
2120
}
2221

23-
/// <remarks />
2422
[Serializable]
2523
[DesignerCategory("code")]
26-
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
24+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
2725
public class WixFragment
2826
{
29-
/// <remarks />
3027
[XmlElement("ComponentGroup", typeof(WixFragmentComponentGroup))]
3128
public object[] Items { get; set; }
3229
}
3330

34-
/// <remarks />
3531
[Serializable]
3632
[DesignerCategory("code")]
37-
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
33+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
3834
public class WixFragmentComponentGroup
3935
{
40-
/// <remarks />
4136
[XmlElement("Component")]
4237
public WixFragmentComponentGroupComponent[] Component { get; set; }
4338

44-
/// <remarks />
4539
[XmlAttribute]
4640
public string Id { get; set; }
4741

48-
/// <remarks />
4942
[XmlAttribute]
5043
public string Directory { get; set; }
5144
}
5245

53-
/// <remarks />
5446
[Serializable]
5547
[DesignerCategory("code")]
56-
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
48+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
5749
public class WixFragmentComponentGroupComponent
5850
{
59-
/// <remarks />
6051
public WixFragmentComponentGroupComponentFile File { get; set; }
6152

62-
/// <remarks />
6353
public WixFragmentComponentGroupComponentRegistryValue RegistryValue { get; set; }
6454
}
6555

66-
/// <remarks />
6756
[Serializable]
6857
[DesignerCategory("code")]
69-
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
70-
public class WixFragmentComponentGroupComponentFile
58+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
59+
public class WixFragmentComponentGroupComponentRegistryValue
7160
{
72-
/// <remarks />
7361
[XmlAttribute]
74-
public string Id { get; set; }
62+
public string Root { get; set; }
7563

76-
/// <remarks />
7764
[XmlAttribute]
7865
public string Name { get; set; }
7966

80-
/// <remarks />
8167
[XmlAttribute]
8268
public string KeyPath { get; set; }
8369

84-
/// <remarks />
8570
[XmlAttribute]
86-
public string Source { get; set; }
71+
public string Key { get; set; }
72+
73+
[XmlElement("MultiStringValue")]
74+
public List<WixFragmentComponentGroupComponentRegistryValueMultiStringValue> MultiStringValue { get; set; }
8775
}
8876

89-
/// <remarks />
9077
[Serializable]
9178
[DesignerCategory("code")]
92-
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
93-
public class WixFragmentComponentGroupComponentRegistryValue
79+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
80+
public class WixFragmentComponentGroupComponentRegistryValueMultiStringValue
81+
{
82+
[XmlAttribute()]
83+
public string Value { get; set; }
84+
}
85+
86+
[Serializable]
87+
[DesignerCategory("code")]
88+
[XmlType(AnonymousType = true, Namespace = "http://wixtoolset.org/schemas/v4/wxs")]
89+
public class WixFragmentComponentGroupComponentFile
9490
{
95-
/// <remarks />
9691
[XmlAttribute]
97-
public string Root { get; set; }
92+
public string Id { get; set; }
9893

99-
/// <remarks />
10094
[XmlAttribute]
10195
public string Name { get; set; }
10296

103-
/// <remarks />
10497
[XmlAttribute]
10598
public string KeyPath { get; set; }
10699

107-
/// <remarks />
108100
[XmlAttribute]
109-
public string Key { get; set; }
110-
111-
[XmlElement(ElementName = "MultiStringValue", Namespace = "http://schemas.microsoft.com/wix/2006/wi")]
112-
public List<string> MultiStringValue { get; set; }
101+
public string Source { get; set; }
113102
}
114103
}
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,11 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="WixToolset.Sdk/5.0.0">
32
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6-
<ProductVersion>3.6</ProductVersion>
7-
<ProjectGuid>b5c13b8f-279b-455b-ace5-864ca37ceb08</ProjectGuid>
8-
<SchemaVersion>2.0</SchemaVersion>
93
<OutputName>Installer</OutputName>
10-
<OutputType>Package</OutputType>
114
<IntermediateOutputPath>$(SolutionDir)..\..\_build\$(Platform)-$(Configuration)\$(OutputName)\</IntermediateOutputPath>
125
<OutputPath>$(SolutionDir)..\..\_build\$(Platform)-$(Configuration)\$(OutputName)\</OutputPath>
13-
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
14-
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
6+
<DebugType>full</DebugType>
157
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
17-
<DefineConstants>Debug</DefineConstants>
18-
</PropertyGroup>
19-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
20-
<DefineConstants>Debug</DefineConstants>
21-
</PropertyGroup>
22-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
23-
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
25-
</PropertyGroup>
26-
<ItemGroup>
27-
<Compile Include="LicenseKeyDialog.wxs" />
28-
<Compile Include="Product.wxs" />
29-
<Compile Include="WizardUI.wxs" />
30-
</ItemGroup>
8+
319
<ItemGroup>
3210
<ProjectReference Include="..\InstallerActions\InstallerActions.csproj">
3311
<Name>InstallerActions</Name>
@@ -38,33 +16,21 @@
3816
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
3917
</ProjectReference>
4018
</ItemGroup>
19+
4120
<ItemGroup>
42-
<WixExtension Include="WixNetFxExtension">
43-
<HintPath>$(WixExtDir)\WixNetFxExtension.dll</HintPath>
44-
<Name>WixNetFxExtension</Name>
45-
</WixExtension>
46-
<WixExtension Include="WixIIsExtension">
47-
<HintPath>$(WixExtDir)\WixIIsExtension.dll</HintPath>
48-
<Name>WixIIsExtension</Name>
49-
</WixExtension>
50-
<WixExtension Include="WixUIExtension">
51-
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
52-
<Name>WixUIExtension</Name>
53-
</WixExtension>
54-
<WixExtension Include="WixUtilExtension">
55-
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
56-
<Name>WixUtilExtension</Name>
57-
</WixExtension>
21+
<PackageReference Include="WixToolset.NetFx.wixext" Version="5.0.0" />
22+
<PackageReference Include="WixToolset.Iis.wixext" Version="5.0.0" />
23+
<PackageReference Include="WixToolset.UI.wixext" Version="5.0.0" />
24+
<PackageReference Include="WixToolset.Util.wixext" Version="5.0.0" />
5825
</ItemGroup>
59-
<Import Project="$(WixTargetsPath)" />
60-
26+
6127
<PropertyGroup>
6228
<WindowsSdkPathBin>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKLocation('Windows', '10.0'))bin</WindowsSdkPathBin>
6329
<WindowsSdkPath>$(WindowsSdkPathBin)\10.0.19041.0</WindowsSdkPath>
6430
<SignToolPath>$(WindowsSdkPath)\x64\signtool.exe</SignToolPath>
6531
</PropertyGroup>
66-
67-
<Target Name="SignInstaller">
32+
33+
<Target Name="SignInstaller" BeforeTargets="AfterBuild">
6834
<Exec Command="&quot;$(SignToolPath)&quot; sign /d &quot;New Relic .NET Agent&quot; /a &quot;$(OutputPath)$(OutputName).msi&quot;" StandardOutputImportance="high" />
6935
<ReadFileVersionFromDll FilePath="$(SolutionDir)..\..\_build\AnyCPU-$(Configuration)\NewRelic.Agent.Core\net462\NewRelic.Agent.Core.dll">
7036
<Output PropertyName="FileVersionString" TaskParameter="FileVersionString" />
@@ -73,21 +39,17 @@
7339
<Delete Files="$(OutputPath)\$(OutputName).msi" />
7440
</Target>
7541

76-
<Target Name="AfterBuild" DependsOnTargets="SignInstaller" />
77-
7842
<UsingTask TaskName="ReadFileVersionFromDll" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
7943
<ParameterGroup>
8044
<FilePath ParameterType="System.String" Required="true" />
8145
<FileVersionString ParameterType="System.String" Output="true" />
8246
</ParameterGroup>
8347
<Task>
8448
<Using Namespace="System.Diagnostics" />
85-
<Code Type="Fragment" Language="cs">
86-
<![CDATA[
49+
<Code Type="Fragment" Language="cs"><![CDATA[
8750
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(FilePath);
8851
FileVersionString = myFileVersionInfo.FileVersion;
89-
]]>
90-
</Code>
52+
]]></Code>
9153
</Task>
9254
</UsingTask>
93-
</Project>
55+
</Project>

src/Agent/MsiInstaller/Installer/LicenseKeyDialog.wxs

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
1+
<!--
32
Copyright 2020 New Relic Corporation. All rights reserved.
43
SPDX-License-Identifier: Apache-2.0
54
-->
6-
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
5+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
76
<Fragment>
8-
<Property Id="PIDTemplate">
9-
<![CDATA[&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&]]>
10-
</Property>
7+
<Property Id="PIDTemplate" Value="&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;" />
118
<UI>
129
<Dialog Id="LicenseKeyDialog" Width="370" Height="270" Title="[ProductName] Setup">
1310
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
1411
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
15-
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}License Key"/>
16-
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please enter your license key"/>
12+
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}License Key" />
13+
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please enter your license key" />
1714
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
1815

19-
<Control Id="LicenseLabel" Type="Text" X="45" Y="147" Width="50" Height="10" TabSkip="no" Text="License Key:"/>
20-
<Control Id="LicenseEdit" Type="MaskedEdit" X="45" Y="159" Width="250" Height="16" Property="NR_LICENSE_KEY" Text="[PIDTemplate]"/>
16+
<Control Id="LicenseLabel" Type="Text" X="45" Y="147" Width="50" Height="10" TabSkip="no" Text="License Key:" />
17+
<Control Id="LicenseEdit" Type="MaskedEdit" X="45" Y="159" Width="250" Height="16" Property="NR_LICENSE_KEY" Text="[PIDTemplate]" />
2118

2219
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
23-
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
20+
<Publish Event="NewDialog" Value="LicenseAgreementDlg" />
2421
</Control>
2522
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
26-
<Publish Event="NewDialog" Value="FeaturesDlg"><![CDATA[NR_LICENSE_KEY <> " "]]></Publish>
23+
<Publish Event="NewDialog" Value="FeaturesDlg" Condition="NR_LICENSE_KEY &lt;&gt; &quot; &quot;" />
2724
</Control>
2825
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
29-
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
26+
<Publish Event="SpawnDialog" Value="CancelDlg" />
3027
</Control>
3128
</Dialog>
3229
</UI>

0 commit comments

Comments
 (0)