Convert iis:Certificate BinaryKey to BinaryRef
Fixes 7341
Rob Mensching committed
Apr 3, 2023 at 22:21 UTC
ef800a635a79effeec25775163002e1c8da9bb98
2 files changed
+71
-1
src/wix/WixToolset.Converters/WixConverter.cs
+20
-1
@@ -52,6 +52,7 @@ namespace WixToolset.Converters
52
private static readonly XNamespace WixDependencyNamespace = "http://wixtoolset.org/schemas/v4/wxs/dependency";
53
private static readonly XNamespace WixDirectXNamespace = "http://wixtoolset.org/schemas/v4/wxs/directx";
54
private static readonly XNamespace WixFirewallNamespace = "http://wixtoolset.org/schemas/v4/wxs/firewall";
55
+ private static readonly XNamespace WixIisNamespace = "http://wixtoolset.org/schemas/v4/wxs/iis";
56
private static readonly XNamespace WixUiNamespace = "http://wixtoolset.org/schemas/v4/wxs/ui";
57
private static readonly XNamespace WixUtilNamespace = "http://wixtoolset.org/schemas/v4/wxs/util";
58
private static readonly XNamespace WixVSNamespace = "http://wixtoolset.org/schemas/v4/wxs/vs";
@@ -76,6 +77,7 @@ namespace WixToolset.Converters
77
private static readonly XName CustomTableElementName = WixNamespace + "CustomTable";
78
private static readonly XName CustomTableRefElementName = WixNamespace + "CustomTableRef";
79
private static readonly XName CatalogElementName = WixNamespace + "Catalog";
80
+ private static readonly XName CertificateElementName = WixIisNamespace + "Certificate";
81
private static readonly XName ColumnElementName = WixNamespace + "Column";
82
private static readonly XName ComponentElementName = WixNamespace + "Component";
83
private static readonly XName ControlElementName = WixNamespace + "Control";
@@ -173,7 +175,7 @@ namespace WixToolset.Converters
175
{ "http://schemas.microsoft.com/wix/DifxAppExtension", "http://wixtoolset.org/schemas/v4/wxs/difxapp" },
176
{ "http://schemas.microsoft.com/wix/FirewallExtension", WixFirewallNamespace },
177
{ "http://schemas.microsoft.com/wix/HttpExtension", "http://wixtoolset.org/schemas/v4/wxs/http" },
176
- { "http://schemas.microsoft.com/wix/IIsExtension", "http://wixtoolset.org/schemas/v4/wxs/iis" },
178
+ { "http://schemas.microsoft.com/wix/IIsExtension", WixIisNamespace },
179
{ "http://schemas.microsoft.com/wix/MsmqExtension", "http://wixtoolset.org/schemas/v4/wxs/msmq" },
180
{ "http://schemas.microsoft.com/wix/NetFxExtension", "http://wixtoolset.org/schemas/v4/wxs/netfx" },
181
{ "http://schemas.microsoft.com/wix/PSExtension", "http://wixtoolset.org/schemas/v4/wxs/powershell" },
@@ -278,6 +280,7 @@ namespace WixToolset.Converters
280
{ WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement },
281
{ WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement },
282
{ WixConverter.CatalogElementName, this.ConvertCatalogElement },
283
+ { WixConverter.CertificateElementName, this.ConvertCertificateElement },
284
{ WixConverter.ColumnElementName, this.ConvertColumnElement },
285
{ WixConverter.ComponentElementName, this.ConvertComponentElement },
286
{ WixConverter.ControlElementName, this.ConvertControlElement },
@@ -864,6 +867,17 @@ namespace WixToolset.Converters
867
}
868
}
869
870
+
871
+ private void ConvertCertificateElement(XElement xCertificate)
872
+ {
873
+ var xBinaryKey = xCertificate.Attribute("BinaryKey");
874
+ if (xBinaryKey != null && this.OnInformation(ConverterTestType.CertificateBinaryKeyIsNowBinaryRef, xCertificate, "The Certificate BinaryKey element has been renamed to BinaryRef."))
875
+ {
876
+ xCertificate.SetAttributeValue("BinaryRef", xBinaryKey.Value);
877
+ xBinaryKey.Remove();
878
+ }
879
+ }
880
+
881
private void ConvertColumnElement(XElement element)
882
{
883
var category = element.Attribute("Category");
@@ -3284,6 +3298,11 @@ namespace WixToolset.Converters
3298
/// A reference to the TARGETDIR Directory was removed. This may cause the Fragment that defined TARGETDIR to not be included in the final output. If this happens, reference a different element in the Fragment to replace the old reference to TARGEDIR.
3299
/// </summary>
3300
TargetDirRefRemoved,
3301
+
3302
+ /// <summary>
3303
+ /// The Certificate BinaryKey element has been renamed to BinaryRef.
3304
+ /// </summary>
3305
+ CertificateBinaryKeyIsNowBinaryRef,
3306
}
3307
}
3308
}
src/wix/test/WixToolsetTest.Converters/IisExtensionFixture.cs
new
+51
@@ -0,0 +1,51 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolsetTest.Converters
4
+{
5
+ using System;
6
+ using System.Xml.Linq;
7
+ using WixInternal.TestSupport;
8
+ using WixToolset.Converters;
9
+ using WixToolsetTest.Converters.Mocks;
10
+ using Xunit;
11
+
12
+ public class IisExtensionFixture : BaseConverterFixture
13
+ {
14
+ [Fact]
15
+ public void FixCertificateBinaryKey()
16
+ {
17
+ var parse = String.Join(Environment.NewLine,
18
+ "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>",
19
+ " <Fragment>",
20
+ " <iis:Certificate BinaryKey=\"SomeBinary\" />",
21
+ " </Fragment>",
22
+ " <Fragment>",
23
+ " <Binary Id=\"SomeBinary\" SourceFile=\"path\\to\\bin.dll\" />",
24
+ " </Fragment>",
25
+ "</Wix>");
26
+
27
+ var expected = new[]
28
+ {
29
+ "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:iis=\"http://wixtoolset.org/schemas/v4/wxs/iis\">",
30
+ " <Fragment>",
31
+ " <iis:Certificate BinaryRef=\"SomeBinary\" />",
32
+ " </Fragment>",
33
+ " <Fragment>",
34
+ " <Binary Id=\"SomeBinary\" SourceFile=\"path\\to\\bin.dll\" />",
35
+ " </Fragment>",
36
+ "</Wix>"
37
+ };
38
+
39
+ var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
40
+
41
+ var messaging = new MockMessaging();
42
+ var converter = new WixConverter(messaging, 2, null, null);
43
+
44
+ var errors = converter.ConvertDocument(document);
45
+ Assert.Equal(3, errors);
46
+
47
+ var actualLines = UnformattedDocumentLines(document);
48
+ WixAssert.CompareLineByLine(expected, actualLines);
49
+ }
50
+ }
51
+}