Fix conversion of Product/@Condition.
Bob Arnson committed
Oct 13, 2020 at 18:59 UTC
61cd9e6baeffa365ea535b09d3cf69731b989a9a
2 files changed
+41
-3
src/WixToolset.Converters/WixConverter.cs
+3
-3
@@ -680,10 +680,10 @@ namespace WixToolset.Converters
680
}
681
}
682
683
- var xCondition = element.Element(ConditionElementName);
684
- if (xCondition != null)
683
+ var xConditions = element.Elements(ConditionElementName).ToList();
684
+ foreach (var xCondition in xConditions)
685
{
686
- var message = element.Attribute("Message")?.Value;
686
+ var message = xCondition.Attribute("Message")?.Value;
687
688
if (!String.IsNullOrEmpty(message) &&
689
TryGetInnerText(xCondition, out var text) &&
src/test/WixToolsetTest.Converters/ConditionFixture.cs
+38
@@ -213,6 +213,44 @@ namespace WixToolsetTest.Converters
213
WixAssert.CompareLineByLine(expected, actualLines);
214
}
215
216
+ [Fact]
217
+ public void FixLaunchConditionInProduct()
218
+ {
219
+ var parse = String.Join(Environment.NewLine,
220
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
221
+ "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
222
+ " <Product>",
223
+ " <Condition Message='Stop the install'>",
224
+ " 1<2",
225
+ " </Condition>",
226
+ " <Condition Message='Do not stop'>",
227
+ " 1=2",
228
+ " </Condition>",
229
+ " </Product>",
230
+ "</Wix>");
231
+
232
+ var expected = new[]
233
+ {
234
+ "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
235
+ " <Product>",
236
+ " <Launch Condition=\"1<2\" Message=\"Stop the install\" />",
237
+ " <Launch Condition=\"1=2\" Message=\"Do not stop\" />",
238
+ " </Product>",
239
+ "</Wix>"
240
+ };
241
+
242
+ var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
243
+
244
+ var messaging = new MockMessaging();
245
+ var converter = new WixConverter(messaging, 2, null, null);
246
+
247
+ var errors = converter.ConvertDocument(document);
248
+ Assert.Equal(4, errors);
249
+
250
+ var actualLines = UnformattedDocumentLines(document);
251
+ WixAssert.CompareLineByLine(expected, actualLines);
252
+ }
253
+
254
[Fact]
255
public void FixPermissionExCondition()
256
{