Convert Tag.wixext to SoftwareTag element
Rob Mensching committed
Feb 26, 2021 at 15:31 UTC
e0ef9e78ad5478abb650bbb004f7494f47896b0d
8 files changed
+80
-15
src/WixToolset.Converters/WixConverter.cs
+22
-2
@@ -80,6 +80,8 @@ namespace WixToolset.Converters
80
private static readonly XName SetDirectoryElementName = WixNamespace + "SetDirectory";
81
private static readonly XName SetPropertyElementName = WixNamespace + "SetProperty";
82
private static readonly XName ShortcutPropertyElementName = WixNamespace + "ShortcutProperty";
83
+ private static readonly XName SoftwareTagElementName = WixNamespace + "SoftwareTag";
84
+ private static readonly XName TagElementName = XNamespace.None + "Tag";
85
private static readonly XName TextElementName = WixNamespace + "Text";
86
private static readonly XName UITextElementName = WixNamespace + "UIText";
87
private static readonly XName VariableElementName = WixNamespace + "Variable";
@@ -117,7 +119,7 @@ namespace WixToolset.Converters
119
{ "http://schemas.microsoft.com/wix/NetFxExtension", "http://wixtoolset.org/schemas/v4/wxs/netfx" },
120
{ "http://schemas.microsoft.com/wix/PSExtension", "http://wixtoolset.org/schemas/v4/wxs/powershell" },
121
{ "http://schemas.microsoft.com/wix/SqlExtension", "http://wixtoolset.org/schemas/v4/wxs/sql" },
120
- { "http://schemas.microsoft.com/wix/TagExtension", "http://wixtoolset.org/schemas/v4/wxs/tag" },
122
+ { "http://schemas.microsoft.com/wix/TagExtension", XNamespace.None },
123
{ "http://schemas.microsoft.com/wix/UtilExtension", WixUtilNamespace },
124
{ "http://schemas.microsoft.com/wix/VSExtension", "http://wixtoolset.org/schemas/v4/wxs/vs" },
125
{ "http://wixtoolset.org/schemas/thmutil/2010", "http://wixtoolset.org/schemas/v4/thmutil" },
@@ -186,6 +188,7 @@ namespace WixToolset.Converters
188
{ WixConverter.SetDirectoryElementName, this.ConvertSetDirectoryElement },
189
{ WixConverter.SetPropertyElementName, this.ConvertSetPropertyElement },
190
{ WixConverter.ShortcutPropertyElementName, this.ConvertShortcutPropertyElement },
191
+ { WixConverter.TagElementName, this.ConvertTagElement },
192
{ WixConverter.TextElementName, this.ConvertTextElement },
193
{ WixConverter.UITextElementName, this.ConvertUITextElement },
194
{ WixConverter.VariableElementName, this.ConvertVariableElement },
@@ -1144,6 +1147,14 @@ namespace WixToolset.Converters
1147
}
1148
}
1149
1150
+ private void ConvertTagElement(XElement element)
1151
+ {
1152
+ if (this.OnError(ConverterTestType.TagElementRenamed, element, "The Tag element has been renamed. Use the element 'SoftwareTag' name."))
1153
+ {
1154
+ element.Name = SoftwareTagElementName;
1155
+ }
1156
+ }
1157
+
1158
private void ConvertTextElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value");
1159
1160
private void ConvertUITextElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value");
@@ -1378,7 +1389,6 @@ namespace WixToolset.Converters
1389
{
1390
foreach (var element in elements)
1391
{
1381
-
1392
if (deprecatedToUpdatedNamespaces.TryGetValue(element.Name.Namespace, out var ns))
1393
{
1394
element.Name = ns.GetName(element.Name.LocalName);
@@ -1396,6 +1406,11 @@ namespace WixToolset.Converters
1406
{
1407
if (deprecatedToUpdatedNamespaces.TryGetValue(attribute.Value, out ns))
1408
{
1409
+ if (ns == XNamespace.None)
1410
+ {
1411
+ continue;
1412
+ }
1413
+
1414
convertedAttribute = ("xmlns" == attribute.Name.LocalName) ? new XAttribute(attribute.Name.LocalName, ns.NamespaceName) : new XAttribute(XNamespace.Xmlns + attribute.Name.LocalName, ns.NamespaceName);
1415
}
1416
}
@@ -1815,6 +1830,11 @@ namespace WixToolset.Converters
1830
/// Breaking change: The Win64 attribute's value '{0}' cannot be converted automatically to the new Bitness attribute.
1831
/// </summary>
1832
Win64AttributeRenameCannotBeAutomatic,
1833
+
1834
+ /// <summary>
1835
+ /// The Tag element has been renamed. Use the element 'SoftwareTag' name.
1836
+ /// </summary>
1837
+ TagElementRenamed,
1838
}
1839
}
1840
}
src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
+4
-4
@@ -58,7 +58,7 @@ namespace WixToolsetTest.Converters
58
var converter = new WixConverter(messaging, 4);
59
var errors = converter.ConvertFile(targetFile, true);
60
61
- Assert.Equal(8, errors);
61
+ Assert.Equal(9, errors);
62
63
var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
64
var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n");
@@ -84,7 +84,7 @@ namespace WixToolsetTest.Converters
84
var settingsFile = Path.Combine(folder, "wixcop.settings.xml");
85
86
var result = RunConversion(targetFile, settingsFile: settingsFile);
87
- Assert.Equal(8, result.ExitCode);
87
+ Assert.Equal(9, result.ExitCode);
88
89
var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
90
var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n");
@@ -108,7 +108,7 @@ namespace WixToolsetTest.Converters
108
File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));
109
110
var result = RunConversion(targetFile);
111
- Assert.Equal(12, result.ExitCode);
111
+ Assert.Equal(13, result.ExitCode);
112
113
var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
114
var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n");
@@ -133,7 +133,7 @@ namespace WixToolsetTest.Converters
133
134
var result = RunConversion(targetFile);
135
136
- Assert.Equal(12, result.ExitCode);
136
+ Assert.Equal(13, result.ExitCode);
137
Assert.Single(result.Messages.Where(message => message.ToString().EndsWith("(QtExecCmdTimeoutAmbiguous)")));
138
139
var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n");
src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs
+1
-1
@@ -9,7 +9,7 @@ namespace WixToolsetTest.Converters
9
using WixToolsetTest.Converters.Mocks;
10
using Xunit;
11
12
- public class ExtensionFixture : BaseConverterFixture
12
+ public class FirewallExtensionFixture : BaseConverterFixture
13
{
14
[Fact]
15
public void FixRemoteAddressValue()
src/test/WixToolsetTest.Converters/TagFixture.cs
new
+45
@@ -0,0 +1,45 @@
1
+// 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.
2
+
3
+namespace WixToolsetTest.Converters
4
+{
5
+ using System;
6
+ using System.Xml.Linq;
7
+ using WixBuildTools.TestSupport;
8
+ using WixToolset.Converters;
9
+ using WixToolsetTest.Converters.Mocks;
10
+ using Xunit;
11
+
12
+ public class TagFixture : BaseConverterFixture
13
+ {
14
+ [Fact]
15
+ public void FixTagExtension()
16
+ {
17
+ var parse = String.Join(Environment.NewLine,
18
+ "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:tag='http://schemas.microsoft.com/wix/TagExtension'>",
19
+ " <Product>",
20
+ " <tag:Tag Regid='wixtoolset.org' InstallDirectory='InstallFolder' />",
21
+ " </Product>",
22
+ "</Wix>");
23
+
24
+ var expected = new[]
25
+ {
26
+ "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
27
+ " <Package>",
28
+ " <SoftwareTag Regid=\"wixtoolset.org\" InstallDirectory=\"InstallFolder\" />",
29
+ " </Package>",
30
+ "</Wix>"
31
+ };
32
+
33
+ var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
34
+
35
+ var messaging = new MockMessaging();
36
+ var converter = new WixConverter(messaging, 2, null, null);
37
+
38
+ var errors = converter.ConvertDocument(document);
39
+ Assert.Equal(4, errors);
40
+
41
+ var actualLines = UnformattedDocumentLines(document);
42
+ WixAssert.CompareLineByLine(expected, actualLines);
43
+ }
44
+ }
45
+}
src/test/WixToolsetTest.Converters/TestData/Preprocessor/ConvertedPreprocessor.wxs
+2
-2
@@ -4,10 +4,10 @@
4
5
<?include WixVer.wxi ?>
6
7
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
7
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
8
<Package Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D" InstallerVersion="200">
9
10
- <swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
10
+ <SoftwareTag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
11
12
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." />
13
src/test/WixToolsetTest.Converters/TestData/QtExec.bad/v4_expected.wxs
+2
-2
@@ -4,10 +4,10 @@
4
5
<?include WixVer.wxi ?>
6
7
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
7
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
8
<Package Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D" InstallerVersion="200">
9
10
- <swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
10
+ <SoftwareTag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
11
12
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." />
13
src/test/WixToolsetTest.Converters/TestData/QtExec/v4_expected.wxs
+2
-2
@@ -4,10 +4,10 @@
4
5
<?include WixVer.wxi ?>
6
7
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
7
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
8
<Package Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D" InstallerVersion="200">
9
10
- <swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
10
+ <SoftwareTag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
11
12
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." />
13
src/test/WixToolsetTest.Converters/TestData/SingleFile/ConvertedSingleFile.wxs
+2
-2
@@ -4,10 +4,10 @@
4
5
<?include WixVer.wxi ?>
6
7
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
7
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
8
<Package Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D" InstallerVersion="200">
9
10
- <swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
10
+ <SoftwareTag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
11
12
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." />
13