aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-07-01 00:10:08 -0700
committerRob Mensching <rob@firegiant.com>2020-07-01 11:26:56 -0700
commit181aa7076a5bdc4d554d29ec9f96dc923e40a6ed (patch)
treee4a4d023b42b98e7b0b867367cd73e318dcdd903 /src
parentea4fe9e10a1236262011f845585ae94154964a86 (diff)
downloadwix-181aa7076a5bdc4d554d29ec9f96dc923e40a6ed.tar.gz
wix-181aa7076a5bdc4d554d29ec9f96dc923e40a6ed.tar.bz2
wix-181aa7076a5bdc4d554d29ec9f96dc923e40a6ed.zip
Make Publish/@Condition truly optional
There is a change to the Core to add the condition back
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Converters/WixConverter.cs11
-rw-r--r--src/test/WixToolsetTest.Converters/ConditionFixture.cs46
2 files changed, 56 insertions, 1 deletions
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
601 } 601 }
602 } 602 }
603 603
604 private void ConvertPublishElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Condition"); 604 private void ConvertPublishElement(XElement element)
605 {
606 this.ConvertInnerTextToAttribute(element, "Condition");
607
608 var xCondition = element.Attribute("Condition");
609 if (xCondition?.Value == "1")
610 {
611 xCondition.Remove();
612 }
613 }
605 614
606 private void ConvertMultiStringValueElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value"); 615 private void ConvertMultiStringValueElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value");
607 616
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
@@ -57,6 +57,52 @@ namespace WixToolsetTest.Converters
57 } 57 }
58 58
59 [Fact] 59 [Fact]
60 public void FixPublishCondition()
61 {
62 var parse = String.Join(Environment.NewLine,
63 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
64 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
65 " <Fragment>",
66 " <UI>",
67 " <Dialog Id='Dlg1'>",
68 " <Control Id='Control1'>",
69 " <Publish Value='abc'>1&lt;2</Publish>",
70 " <Publish Value='gone'>1</Publish>",
71 " </Control>",
72 " </Dialog>",
73 " </UI>",
74 " </Fragment>",
75 "</Wix>");
76
77 var expected = new[]
78 {
79 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
80 " <Fragment>",
81 " <UI>",
82 " <Dialog Id=\"Dlg1\">",
83 " <Control Id=\"Control1\">",
84 " <Publish Value=\"abc\" Condition=\"1&lt;2\" />",
85 " <Publish Value=\"gone\" />",
86 " </Control>",
87 " </Dialog>",
88 " </UI>",
89 " </Fragment>",
90 "</Wix>"
91 };
92
93 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
94
95 var messaging = new MockMessaging();
96 var converter = new WixConverter(messaging, 2, null, null);
97
98 var errors = converter.ConvertDocument(document);
99 Assert.Equal(4, errors);
100
101 var actualLines = UnformattedDocumentLines(document);
102 CompareLineByLine(expected, actualLines);
103 }
104
105 [Fact]
60 public void FixComponentCondition() 106 public void FixComponentCondition()
61 { 107 {
62 var parse = String.Join(Environment.NewLine, 108 var parse = String.Join(Environment.NewLine,