Warn about inability to convert Verb/@Target.
Bob Arnson committed
Nov 9, 2020 at 15:50 UTC
d4a7583d9df4a3ac14f8c000802fb500b9948a29
2 files changed
+42
src/WixToolset.Converters/WixConverter.cs
+16
@@ -76,6 +76,7 @@ namespace WixToolset.Converters
76
private static readonly XName TextElementName = WixNamespace + "Text";
77
private static readonly XName UITextElementName = WixNamespace + "UIText";
78
private static readonly XName VariableElementName = WixNamespace + "Variable";
79
+ private static readonly XName VerbElementName = WixNamespace + "Verb";
80
private static readonly XName UtilCloseApplicationElementName = WixUtilNamespace + "CloseApplication";
81
private static readonly XName UtilPermissionExElementName = WixUtilNamespace + "PermissionEx";
82
private static readonly XName UtilRegistrySearchName = WixUtilNamespace + "RegistrySearch";
@@ -177,6 +178,7 @@ namespace WixToolset.Converters
178
{ WixConverter.PropertyElementName, this.ConvertPropertyElement },
179
{ WixConverter.WixElementWithoutNamespaceName, this.ConvertElementWithoutNamespace },
180
{ WixConverter.IncludeElementWithoutNamespaceName, this.ConvertElementWithoutNamespace },
181
+ { WixConverter.VerbElementName, this.ConvertVerbElement },
182
};
183
184
this.Messaging = messaging;
@@ -768,6 +770,7 @@ namespace WixToolset.Converters
770
RemoveAttribute(xSummaryInformation, "Id");
771
MoveAttribute(xSummaryInformation, "InstallerVersion", xPackage, defaultValue: "500");
772
MoveAttribute(xSummaryInformation, "InstallScope", xPackage, "Scope", defaultValue: "perMachine");
773
+ RemoveAttribute(xSummaryInformation, "Languages");
774
RemoveAttribute(xSummaryInformation, "Platform");
775
RemoveAttribute(xSummaryInformation, "Platforms");
776
RemoveAttribute(xSummaryInformation, "ReadOnly");
@@ -887,6 +890,14 @@ namespace WixToolset.Converters
890
}
891
}
892
893
+ private void ConvertVerbElement(XElement element)
894
+ {
895
+ if (null != element.Attribute("Target"))
896
+ {
897
+ this.OnError(ConverterTestType.VerbTargetNotConvertable, element, "The Verb/@Target attribute has been replaced with typed @TargetFile and @TargetProperty attributes.");
898
+ }
899
+ }
900
+
901
private void ConvertCustomActionElement(XElement xCustomAction)
902
{
903
var xBinaryKey = xCustomAction.Attribute("BinaryKey");
@@ -1473,6 +1484,11 @@ namespace WixToolset.Converters
1484
/// InstallerVersion has breaking change when missing.
1485
/// </summary>
1486
InstallerVersionBehaviorChange,
1487
+
1488
+ /// <summary>
1489
+ /// Verb/@Target can't be converted.
1490
+ /// </summary>
1491
+ VerbTargetNotConvertable,
1492
}
1493
}
1494
}
src/test/WixToolsetTest.Converters/ConverterFixture.cs
+26
@@ -355,5 +355,31 @@ namespace WixToolsetTest.Converters
355
Assert.Equal(1, errors);
356
Assert.Equal(expected, actual);
357
}
358
+
359
+ [Fact]
360
+ public void CantConvertVerbTarget()
361
+ {
362
+ var parse = String.Join(Environment.NewLine,
363
+ "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
364
+ " <Verb Target='anything' />",
365
+ "</Wix>");
366
+
367
+ var expected = String.Join(Environment.NewLine,
368
+ "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
369
+ " <Verb Target=\"anything\" />",
370
+ "</Wix>");
371
+
372
+ var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
373
+
374
+ var messaging = new MockMessaging();
375
+ var converter = new WixConverter(messaging, 2, null, null);
376
+
377
+ var errors = converter.ConvertDocument(document);
378
+
379
+ var actual = UnformattedDocumentString(document);
380
+
381
+ Assert.Equal(2, errors);
382
+ Assert.Equal(expected, actual);
383
+ }
384
}
385
}