From 181aa7076a5bdc4d554d29ec9f96dc923e40a6ed Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Jul 2020 00:10:08 -0700 Subject: Make Publish/@Condition truly optional There is a change to the Core to add the condition back --- src/WixToolset.Converters/WixConverter.cs | 11 +++++- .../WixToolsetTest.Converters/ConditionFixture.cs | 46 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 73538d56..c18b095e 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs @@ -601,7 +601,16 @@ namespace WixToolset.Converters } } - private void ConvertPublishElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Condition"); + private void ConvertPublishElement(XElement element) + { + this.ConvertInnerTextToAttribute(element, "Condition"); + + var xCondition = element.Attribute("Condition"); + if (xCondition?.Value == "1") + { + xCondition.Remove(); + } + } private void ConvertMultiStringValueElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value"); diff --git a/src/test/WixToolsetTest.Converters/ConditionFixture.cs b/src/test/WixToolsetTest.Converters/ConditionFixture.cs index 1b8a7604..34f99306 100644 --- a/src/test/WixToolsetTest.Converters/ConditionFixture.cs +++ b/src/test/WixToolsetTest.Converters/ConditionFixture.cs @@ -56,6 +56,52 @@ namespace WixToolsetTest.Converters CompareLineByLine(expected, actualLines); } + [Fact] + public void FixPublishCondition() + { + var parse = String.Join(Environment.NewLine, + "", + "", + " ", + " ", + " ", + " ", + " 1<2", + " 1", + " ", + " ", + " ", + " ", + ""); + + 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(4, errors); + + var actualLines = UnformattedDocumentLines(document); + CompareLineByLine(expected, actualLines); + } + [Fact] public void FixComponentCondition() { -- cgit v1.2.3-55-g6feb