From ef800a635a79effeec25775163002e1c8da9bb98 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 3 Apr 2023 22:21:18 -0700 Subject: Convert iis:Certificate BinaryKey to BinaryRef Fixes 7341 --- src/wix/WixToolset.Converters/WixConverter.cs | 21 ++++++++- .../IisExtensionFixture.cs | 51 ++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/wix/test/WixToolsetTest.Converters/IisExtensionFixture.cs diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs index f2711300..2f00d15d 100644 --- a/src/wix/WixToolset.Converters/WixConverter.cs +++ b/src/wix/WixToolset.Converters/WixConverter.cs @@ -52,6 +52,7 @@ namespace WixToolset.Converters private static readonly XNamespace WixDependencyNamespace = "http://wixtoolset.org/schemas/v4/wxs/dependency"; private static readonly XNamespace WixDirectXNamespace = "http://wixtoolset.org/schemas/v4/wxs/directx"; private static readonly XNamespace WixFirewallNamespace = "http://wixtoolset.org/schemas/v4/wxs/firewall"; + private static readonly XNamespace WixIisNamespace = "http://wixtoolset.org/schemas/v4/wxs/iis"; private static readonly XNamespace WixUiNamespace = "http://wixtoolset.org/schemas/v4/wxs/ui"; private static readonly XNamespace WixUtilNamespace = "http://wixtoolset.org/schemas/v4/wxs/util"; private static readonly XNamespace WixVSNamespace = "http://wixtoolset.org/schemas/v4/wxs/vs"; @@ -76,6 +77,7 @@ namespace WixToolset.Converters private static readonly XName CustomTableElementName = WixNamespace + "CustomTable"; private static readonly XName CustomTableRefElementName = WixNamespace + "CustomTableRef"; private static readonly XName CatalogElementName = WixNamespace + "Catalog"; + private static readonly XName CertificateElementName = WixIisNamespace + "Certificate"; private static readonly XName ColumnElementName = WixNamespace + "Column"; private static readonly XName ComponentElementName = WixNamespace + "Component"; private static readonly XName ControlElementName = WixNamespace + "Control"; @@ -173,7 +175,7 @@ namespace WixToolset.Converters { "http://schemas.microsoft.com/wix/DifxAppExtension", "http://wixtoolset.org/schemas/v4/wxs/difxapp" }, { "http://schemas.microsoft.com/wix/FirewallExtension", WixFirewallNamespace }, { "http://schemas.microsoft.com/wix/HttpExtension", "http://wixtoolset.org/schemas/v4/wxs/http" }, - { "http://schemas.microsoft.com/wix/IIsExtension", "http://wixtoolset.org/schemas/v4/wxs/iis" }, + { "http://schemas.microsoft.com/wix/IIsExtension", WixIisNamespace }, { "http://schemas.microsoft.com/wix/MsmqExtension", "http://wixtoolset.org/schemas/v4/wxs/msmq" }, { "http://schemas.microsoft.com/wix/NetFxExtension", "http://wixtoolset.org/schemas/v4/wxs/netfx" }, { "http://schemas.microsoft.com/wix/PSExtension", "http://wixtoolset.org/schemas/v4/wxs/powershell" }, @@ -278,6 +280,7 @@ namespace WixToolset.Converters { WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement }, { WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement }, { WixConverter.CatalogElementName, this.ConvertCatalogElement }, + { WixConverter.CertificateElementName, this.ConvertCertificateElement }, { WixConverter.ColumnElementName, this.ConvertColumnElement }, { WixConverter.ComponentElementName, this.ConvertComponentElement }, { WixConverter.ControlElementName, this.ConvertControlElement }, @@ -864,6 +867,17 @@ namespace WixToolset.Converters } } + + private void ConvertCertificateElement(XElement xCertificate) + { + var xBinaryKey = xCertificate.Attribute("BinaryKey"); + if (xBinaryKey != null && this.OnInformation(ConverterTestType.CertificateBinaryKeyIsNowBinaryRef, xCertificate, "The Certificate BinaryKey element has been renamed to BinaryRef.")) + { + xCertificate.SetAttributeValue("BinaryRef", xBinaryKey.Value); + xBinaryKey.Remove(); + } + } + private void ConvertColumnElement(XElement element) { var category = element.Attribute("Category"); @@ -3284,6 +3298,11 @@ namespace WixToolset.Converters /// 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. /// TargetDirRefRemoved, + + /// + /// The Certificate BinaryKey element has been renamed to BinaryRef. + /// + CertificateBinaryKeyIsNowBinaryRef, } } } diff --git a/src/wix/test/WixToolsetTest.Converters/IisExtensionFixture.cs b/src/wix/test/WixToolsetTest.Converters/IisExtensionFixture.cs new file mode 100644 index 00000000..b20ac90d --- /dev/null +++ b/src/wix/test/WixToolsetTest.Converters/IisExtensionFixture.cs @@ -0,0 +1,51 @@ +// 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. + +namespace WixToolsetTest.Converters +{ + using System; + using System.Xml.Linq; + using WixInternal.TestSupport; + using WixToolset.Converters; + using WixToolsetTest.Converters.Mocks; + using Xunit; + + public class IisExtensionFixture : BaseConverterFixture + { + [Fact] + public void FixCertificateBinaryKey() + { + var parse = String.Join(Environment.NewLine, + "", + " ", + " ", + " ", + " ", + " ", + " ", + ""); + + var expected = new[] + { + "", + " ", + " ", + " ", + " ", + " ", + " ", + "" + }; + + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); + + var messaging = new MockMessaging(); + var converter = new WixConverter(messaging, 2, null, null); + + var errors = converter.ConvertDocument(document); + Assert.Equal(3, errors); + + var actualLines = UnformattedDocumentLines(document); + WixAssert.CompareLineByLine(expected, actualLines); + } + } +} -- cgit v1.2.3-55-g6feb