aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBevan Weiss <bevan.weiss@gmail.com>2025-01-17 22:21:30 +1100
committerRob Mensching <rob@firegiant.com>2025-02-11 07:39:20 -0800
commitb95bf23bb3b69276147a10a43549586aad58713d (patch)
tree3044b6528d66589caf7f1c66dd1b764efb6896ca
parent63223d5c023846ab7b4cef222326c913d2e0521f (diff)
downloadwix-b95bf23bb3b69276147a10a43549586aad58713d.tar.gz
wix-b95bf23bb3b69276147a10a43549586aad58713d.tar.bz2
wix-b95bf23bb3b69276147a10a43549586aad58713d.zip
Raise conversion warning for After and Before attributes, at least on
Sequence and SetProperty elements Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
-rw-r--r--src/wix/WixToolset.Converters/WixConverter.cs19
-rw-r--r--src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs35
-rw-r--r--src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs47
3 files changed, 95 insertions, 6 deletions
diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs
index faa77da9..79539f0c 100644
--- a/src/wix/WixToolset.Converters/WixConverter.cs
+++ b/src/wix/WixToolset.Converters/WixConverter.cs
@@ -211,7 +211,7 @@ namespace WixToolset.Converters
211 { "WixSchedHttpUrlReservationsInstall", "Wix4SchedHttpUrlReservationsInstall_<PlatformSuffix>" }, 211 { "WixSchedHttpUrlReservationsInstall", "Wix4SchedHttpUrlReservationsInstall_<PlatformSuffix>" },
212 { "ConfigureIIs", "Wix4ConfigureIIs_<PlatformSuffix>" }, 212 { "ConfigureIIs", "Wix4ConfigureIIs_<PlatformSuffix>" },
213 { "UninstallCertificates", "Wix4UninstallCertificates_<PlatformSuffix>" }, 213 { "UninstallCertificates", "Wix4UninstallCertificates_<PlatformSuffix>" },
214 { "InstallCertificates", "Wix4_<PlatformSuffix>" }, 214 { "InstallCertificates", "Wix4InstallCertificates_<PlatformSuffix>" },
215 { "MessageQueuingUninstall", "Wix4MessageQueuingUninstall_<PlatformSuffix>" }, 215 { "MessageQueuingUninstall", "Wix4MessageQueuingUninstall_<PlatformSuffix>" },
216 { "MessageQueuingInstall", "Wix4_MessageQueuingInstall<PlatformSuffix>" }, 216 { "MessageQueuingInstall", "Wix4_MessageQueuingInstall<PlatformSuffix>" },
217 { "NetFxScheduleNativeImage", "Wix4NetFxScheduleNativeImage_<PlatformSuffix>" }, 217 { "NetFxScheduleNativeImage", "Wix4NetFxScheduleNativeImage_<PlatformSuffix>" },
@@ -914,13 +914,18 @@ namespace WixToolset.Converters
914 914
915 private void ConvertCustomElement(XElement element) 915 private void ConvertCustomElement(XElement element)
916 { 916 {
917 var actionId = element.Attribute("Action")?.Value; 917 var attributes = new string[] { "Action", "After", "Before" };
918 918
919 if (actionId != null 919 foreach (var attribute in attributes)
920 && CustomActionIdsWithPlatformSuffix.TryGetValue(actionId, out var replacementId))
921 { 920 {
922 this.OnError(ConverterTestType.CustomActionIdsIncludePlatformSuffix, element, 921 var attributeValue = element.Attribute(attribute)?.Value;
923 $"Custom action ids have changed in WiX v4 extensions to support platform-specific custom actions. The platform is applied as a suffix: _X86, _X64, _A64 (Arm64). When manually rescheduling custom action '{actionId}', you must use the new custom action id '{replacementId}'. See the conversion FAQ for more information: https://wixtoolset.org/docs/fourthree/faqs/#converting-packages"); 922
923 if (attributeValue != null
924 && CustomActionIdsWithPlatformSuffix.TryGetValue(attributeValue, out var replacementId))
925 {
926 this.OnError(ConverterTestType.CustomActionIdsIncludePlatformSuffix, element,
927 $"Custom action ids have changed in WiX v4 extensions to support platform-specific custom actions. The platform is applied as a suffix: _X86, _X64, _A64 (Arm64). When manually rescheduling custom action '{attributeValue}', you must use the new custom action id '{replacementId}'. See the conversion FAQ for more information: https://wixtoolset.org/docs/fourthree/faqs/#converting-packages");
928 }
924 } 929 }
925 } 930 }
926 931
@@ -1830,6 +1835,7 @@ namespace WixToolset.Converters
1830 { 1835 {
1831 foreach (var child in element.Elements()) 1836 foreach (var child in element.Elements())
1832 { 1837 {
1838 this.ConvertCustomActionElement(child);
1833 this.ConvertInnerTextToAttribute(child, "Condition"); 1839 this.ConvertInnerTextToAttribute(child, "Condition");
1834 } 1840 }
1835 } 1841 }
@@ -1846,6 +1852,7 @@ namespace WixToolset.Converters
1846 1852
1847 private void ConvertSetPropertyElement(XElement element) 1853 private void ConvertSetPropertyElement(XElement element)
1848 { 1854 {
1855 this.ConvertCustomElement(element);
1849 this.ConvertInnerTextToAttribute(element, "Condition"); 1856 this.ConvertInnerTextToAttribute(element, "Condition");
1850 } 1857 }
1851 1858
diff --git a/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs b/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs
index 9013877a..6ab5fc67 100644
--- a/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs
+++ b/src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs
@@ -45,5 +45,40 @@ namespace WixToolsetTest.Converters
45 var actualLines = UnformattedDocumentLines(document); 45 var actualLines = UnformattedDocumentLines(document);
46 WixAssert.CompareLineByLine(expected, actualLines); 46 WixAssert.CompareLineByLine(expected, actualLines);
47 } 47 }
48
49 [Fact]
50 public void FixConditionWixCa()
51 {
52 var parse = String.Join(Environment.NewLine,
53 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
54 " <Fragment>",
55 " <InstallUISequence>",
56 " <Custom Action='ExampleCA' After='WixQueryOsDirs'>NOT Installed</Custom>",
57 " </InstallUISequence>",
58 " </Fragment>",
59 "</Wix>");
60
61 var expected = new[]
62 {
63 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
64 " <Fragment>",
65 " <InstallUISequence>",
66 " <Custom Action=\"ExampleCA\" After=\"WixQueryOsDirs\" Condition=\"NOT Installed\" />",
67 " </InstallUISequence>",
68 " </Fragment>",
69 "</Wix>"
70 };
71
72 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
73
74 var messaging = new MockMessaging();
75 var converter = new WixConverter(messaging, 2, null, null);
76
77 var errors = converter.ConvertDocument(document);
78 Assert.Equal(3, errors);
79
80 var actualLines = UnformattedDocumentLines(document);
81 WixAssert.CompareLineByLine(expected, actualLines);
82 }
48 } 83 }
49} 84}
diff --git a/src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs b/src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs
new file mode 100644
index 00000000..8c680ba1
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.Converters/SetPropertyFixture.cs
@@ -0,0 +1,47 @@
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
3namespace WixToolsetTest.Converters
4{
5 using System;
6 using System.Xml.Linq;
7 using WixInternal.TestSupport;
8 using WixToolset.Converters;
9 using WixToolsetTest.Converters.Mocks;
10 using Xunit;
11
12 public class SetPropertyFixture : BaseConverterFixture
13 {
14 [Fact]
15 public void FixConditionWixCa()
16 {
17 var parse = String.Join(Environment.NewLine,
18 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
19 " <Fragment>",
20 " <SetProperty Id='INSTALLFOLDER' ",
21 " After='WixQueryOsDirs'" +
22 " Value='test'>NOT Installed</SetProperty>",
23 " </Fragment>",
24 "</Wix>");
25
26 var expected = new[]
27 {
28 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
29 " <Fragment>",
30 " <SetProperty Id=\"INSTALLFOLDER\" After=\"WixQueryOsDirs\" Value=\"test\" Condition=\"NOT Installed\" />",
31 " </Fragment>",
32 "</Wix>"
33 };
34
35 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
36
37 var messaging = new MockMessaging();
38 var converter = new WixConverter(messaging, 2, null, null);
39
40 var errors = converter.ConvertDocument(document);
41 Assert.Equal(3, errors);
42
43 var actualLines = UnformattedDocumentLines(document);
44 WixAssert.CompareLineByLine(expected, actualLines);
45 }
46 }
47}