From 2accc355d9dadb2688cf226f8736232d583281aa Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 8 Jan 2021 15:33:32 -0800 Subject: Rename ExePackage/@XxxCommand attributes to @XxxArguments Fixes wixtoolset/issues#6245 --- src/WixToolset.Converters/WixConverter.cs | 25 ++++++++++- .../WixToolsetTest.Converters/ExePackageFixture.cs | 49 ++++++++++++++++++++++ .../WixToolsetTest.Converters.csproj | 4 +- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 src/test/WixToolsetTest.Converters/ExePackageFixture.cs (limited to 'src') diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index d0c40050..a7f08b88 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs @@ -161,7 +161,7 @@ namespace WixToolset.Converters { WixConverter.FirewallRemoteAddressElementName, this.ConvertFirewallRemoteAddressElement }, { WixConverter.EmbeddedChainerElementName, this.ConvertEmbeddedChainerElement }, { WixConverter.ErrorElementName, this.ConvertErrorElement }, - { WixConverter.ExePackageElementName, this.ConvertSuppressSignatureValidation }, + { WixConverter.ExePackageElementName, this.ConvertExePackageElement }, { WixConverter.ModuleElementName, this.ConvertModuleElement }, { WixConverter.MsiPackageElementName, this.ConvertWindowsInstallerPackageElement }, { WixConverter.MspPackageElementName, this.ConvertWindowsInstallerPackageElement }, @@ -843,6 +843,24 @@ namespace WixToolset.Converters private void ConvertErrorElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Message"); + private void ConvertExePackageElement(XElement element) + { + this.ConvertSuppressSignatureValidation(element); + + foreach (var attributeName in new[] { "InstallCommand", "RepairCommand", "UninstallCommand" }) + { + var newName = attributeName.Replace("Command", "Arguments"); + var attribute = element.Attribute(attributeName); + + if (attribute != null && + this.OnError(ConverterTestType.RenameExePackageCommandToArguments, element, "The {0} element {1} attribute has been renamed {2}.", element.Name.LocalName, attribute.Name.LocalName, newName)) + { + element.Add(new XAttribute(newName, attribute.Value)); + attribute.Remove(); + } + } + } + private void ConvertPermissionExElement(XElement element) { var xCondition = element.Element(ConditionElementName); @@ -1691,6 +1709,11 @@ namespace WixToolset.Converters /// The custom elements for built-in BAs are now required. /// BalBootstrapperApplicationRefToElement, + + /// + /// The ExePackage elements "XxxCommand" attributes have been renamed to "XxxArguments". + /// + RenameExePackageCommandToArguments, } } } diff --git a/src/test/WixToolsetTest.Converters/ExePackageFixture.cs b/src/test/WixToolsetTest.Converters/ExePackageFixture.cs new file mode 100644 index 00000000..0ee8d065 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/ExePackageFixture.cs @@ -0,0 +1,49 @@ +// 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 WixBuildTools.TestSupport; + using WixToolset.Converters; + using WixToolsetTest.Converters.Mocks; + using Xunit; + + public class ExePackageFixture : BaseConverterFixture + { + [Fact] + public void CanConvertExePackageCommandToArguments() + { + 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); + } + } +} diff --git a/src/test/WixToolsetTest.Converters/WixToolsetTest.Converters.csproj b/src/test/WixToolsetTest.Converters/WixToolsetTest.Converters.csproj index 1bf44dbc..902494a2 100644 --- a/src/test/WixToolsetTest.Converters/WixToolsetTest.Converters.csproj +++ b/src/test/WixToolsetTest.Converters/WixToolsetTest.Converters.csproj @@ -36,8 +36,8 @@ - + - + -- cgit v1.2.3-55-g6feb