Skip to content

Commit 614a562

Browse files
committed
Raise conversion warning for After and Before attributes, at least on
Sequence and SetProperty elements Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
1 parent 523c66a commit 614a562

File tree

3 files changed

+95
-6
lines changed

3 files changed

+95
-6
lines changed

src/wix/WixToolset.Converters/WixConverter.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public sealed class WixConverter
211211
{ "WixSchedHttpUrlReservationsInstall", "Wix4SchedHttpUrlReservationsInstall_<PlatformSuffix>" },
212212
{ "ConfigureIIs", "Wix4ConfigureIIs_<PlatformSuffix>" },
213213
{ "UninstallCertificates", "Wix4UninstallCertificates_<PlatformSuffix>" },
214-
{ "InstallCertificates", "Wix4_<PlatformSuffix>" },
214+
{ "InstallCertificates", "Wix4InstallCertificates_<PlatformSuffix>" },
215215
{ "MessageQueuingUninstall", "Wix4MessageQueuingUninstall_<PlatformSuffix>" },
216216
{ "MessageQueuingInstall", "Wix4_MessageQueuingInstall<PlatformSuffix>" },
217217
{ "NetFxScheduleNativeImage", "Wix4NetFxScheduleNativeImage_<PlatformSuffix>" },
@@ -914,13 +914,18 @@ private void ConvertColumnElement(XElement element)
914914

915915
private void ConvertCustomElement(XElement element)
916916
{
917-
var actionId = element.Attribute("Action")?.Value;
917+
var attributes = new string[] { "Action", "After", "Before" };
918918

919-
if (actionId != null
920-
&& CustomActionIdsWithPlatformSuffix.TryGetValue(actionId, out var replacementId))
919+
foreach (var attribute in attributes)
921920
{
922-
this.OnError(ConverterTestType.CustomActionIdsIncludePlatformSuffix, element,
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");
921+
var attributeValue = element.Attribute(attribute)?.Value;
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+
}
924929
}
925930
}
926931

@@ -1830,6 +1835,7 @@ private void ConvertSequenceElement(XElement element)
18301835
{
18311836
foreach (var child in element.Elements())
18321837
{
1838+
this.ConvertCustomActionElement(child);
18331839
this.ConvertInnerTextToAttribute(child, "Condition");
18341840
}
18351841
}
@@ -1846,6 +1852,7 @@ private void ConvertSetDirectoryElement(XElement element)
18461852

18471853
private void ConvertSetPropertyElement(XElement element)
18481854
{
1855+
this.ConvertCustomElement(element);
18491856
this.ConvertInnerTextToAttribute(element, "Condition");
18501857
}
18511858

src/wix/test/WixToolsetTest.Converters/SequenceFixture.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,40 @@ public void FixCondition()
4545
var actualLines = UnformattedDocumentLines(document);
4646
WixAssert.CompareLineByLine(expected, actualLines);
4747
}
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+
}
4883
}
4984
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
3+
namespace 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+
}

0 commit comments

Comments
 (0)