Fix parsing ProviderKey for Bundle.
Sean Hall committed
Mar 5, 2021 at 18:28 UTC
7fa2390b06b643ec775d00d7938c1624f5c0fdfe
3 files changed
+74
-5
src/WixToolset.Core/Compiler_Bundle.cs
+13
-3
@@ -197,7 +197,7 @@ namespace WixToolset.Core
197
parentName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
198
break;
199
case "ProviderKey":
200
- this.ParseBundleProviderKeyAttribute(sourceLineNumbers, node, attrib);
200
+ // This can't be processed until we create the section.
201
break;
202
case "SplashScreenSourceFile":
203
splashScreenSourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
@@ -261,10 +261,20 @@ namespace WixToolset.Core
261
this.activeName = String.IsNullOrEmpty(name) ? Common.GenerateGuid() : name;
262
this.Core.CreateActiveSection(this.activeName, SectionType.Bundle, 0, this.Context.CompilationId);
263
264
- // Now that the active section is initialized, process only extension attributes.
264
+ // Now that the active section is initialized, process only extension attributes and the special ProviderKey attribute.
265
foreach (var attrib in node.Attributes())
266
{
267
- if (!String.IsNullOrEmpty(attrib.Name.NamespaceName) && CompilerCore.WixNamespace != attrib.Name.Namespace)
267
+ if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
268
+ {
269
+ switch (attrib.Name.LocalName)
270
+ {
271
+ case "ProviderKey":
272
+ this.ParseBundleProviderKeyAttribute(sourceLineNumbers, node, attrib);
273
+ break;
274
+ // Unknown attributes were reported earlier.
275
+ }
276
+ }
277
+ else
278
{
279
this.Core.ParseExtensionAttribute(node, attrib);
280
}
src/test/WixToolsetTest.CoreIntegration/DependencyExtensionFixture.cs
+51
-2
@@ -57,12 +57,61 @@ namespace WixToolsetTest.CoreIntegration
57
var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath);
58
extractResult.AssertSuccess();
59
60
- var provides = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Chain/burn:MsiPackage/burn:Provides");
60
+ var provides = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Chain/burn:MsiPackage/burn:Provides")
61
+ .Cast<XmlElement>()
62
+ .Select(e => e.GetTestXml())
63
+ .ToArray();
64
WixAssert.CompareLineByLine(new string[]
65
{
66
"<Provides Key='UsingProvides' Imported='yes' />",
67
"<Provides Key='{A81D50F9-B696-4F3D-ABE0-E64D61590E5F}' Version='1.0.0.0' DisplayName='MsiPackage' />",
65
- }, provides.Cast<XmlElement>().Select(e => e.GetTestXml()).ToArray());
68
+ }, provides);
69
+ }
70
+ }
71
+
72
+ [Fact]
73
+ public void CanBuildBundleWithCustomProviderKey()
74
+ {
75
+ var folder = TestData.Get(@"TestData");
76
+
77
+ using (var fs = new DisposableFileSystem())
78
+ {
79
+ var baseFolder = fs.GetFolder();
80
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
81
+ var binFolder = Path.Combine(baseFolder, "bin");
82
+ var bundlePath = Path.Combine(binFolder, "test.exe");
83
+ var baFolderPath = Path.Combine(baseFolder, "ba");
84
+ var extractFolderPath = Path.Combine(baseFolder, "extract");
85
+
86
+ var result = WixRunner.Execute(new[]
87
+ {
88
+ "build",
89
+ Path.Combine(folder, "Dependency", "CustomProviderKeyBundle.wxs"),
90
+ Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"),
91
+ "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
92
+ "-intermediateFolder", intermediateFolder,
93
+ "-o", bundlePath,
94
+ });
95
+
96
+ result.AssertSuccess();
97
+
98
+ Assert.True(File.Exists(bundlePath));
99
+
100
+ var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath);
101
+ extractResult.AssertSuccess();
102
+
103
+ var ignoreAttributesByElementName = new Dictionary<string, List<string>>
104
+ {
105
+ { "Registration", new List<string> { "Id" } },
106
+ };
107
+ var registration = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Registration")
108
+ .Cast<XmlElement>()
109
+ .Select(e => e.GetTestXml(ignoreAttributesByElementName))
110
+ .ToArray();
111
+ WixAssert.CompareLineByLine(new string[]
112
+ {
113
+ "<Registration Id='*' ExecutableName='test.exe' PerMachine='yes' Tag='' Version='1.0.0.0' ProviderKey='MyProviderKey,v1.0'><Arp Register='yes' DisplayName='BurnBundle' DisplayVersion='1.0.0.0' Publisher='Example Corporation' /></Registration>",
114
+ }, registration);
115
}
116
}
117
src/test/WixToolsetTest.CoreIntegration/TestData/Dependency/CustomProviderKeyBundle.wxs
new
+10
@@ -0,0 +1,10 @@
1
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2
+ <Bundle Name="BurnBundle" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B94478B1-E1F3-4700-9CE8-6AA090854AEC" ProviderKey="MyProviderKey,v1.0">
3
+ <BootstrapperApplication>
4
+ <BootstrapperApplicationDll SourceFile="fakeba.dll" />
5
+ </BootstrapperApplication>
6
+ <Chain>
7
+ <PackageGroupRef Id="MinimalPackageGroup" />
8
+ </Chain>
9
+ </Bundle>
10
+</Wix>