Ensure to reference the before/after WixAction when scheduling an action
Fixes 7225
Rob Mensching committed
Feb 21, 2023 at 22:45 UTC
793a52ae8cbb8873bc23582e4c13e63d729d0bc7
4 files changed
+101
-53
src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+2
-21
@@ -780,28 +780,9 @@ namespace WixToolset.Core.ExtensibilityServices
780
Overridable = overridable,
781
});
782
783
- if (null != beforeAction)
783
+ if (beforeAction != null || afterAction != null)
784
{
785
- if (WindowsInstallerStandard.IsStandardAction(beforeAction))
786
- {
787
- this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), beforeAction);
788
- }
789
- else
790
- {
791
- this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, beforeAction);
792
- }
793
- }
794
-
795
- if (null != afterAction)
796
- {
797
- if (WindowsInstallerStandard.IsStandardAction(afterAction))
798
- {
799
- this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), afterAction);
800
- }
801
- else
802
- {
803
- this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, afterAction);
804
- }
785
+ this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), beforeAction ?? afterAction);
786
}
787
788
return actionSymbol;
src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs
+60
@@ -6,10 +6,70 @@ namespace WixToolsetTest.CoreIntegration
6
using System.Linq;
7
using WixInternal.TestSupport;
8
using WixInternal.Core.TestPackage;
9
+ using WixToolset.Data.WindowsInstaller;
10
using Xunit;
11
12
public class CustomActionFixture
13
{
14
+ [Fact]
15
+ public void CanBuildSetProperty()
16
+ {
17
+ var folder = TestData.Get("TestData", "SetProperty");
18
+
19
+ using (var fs = new DisposableFileSystem())
20
+ {
21
+ var baseFolder = fs.GetFolder();
22
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
23
+
24
+ var result = WixRunner.Execute(new[]
25
+ {
26
+ "build",
27
+ Path.Combine(folder, "Package.wxs"),
28
+ Path.Combine(folder, "PackageComponents.wxs"),
29
+ "-loc", Path.Combine(folder, "Package.en-us.wxl"),
30
+ "-bindpath", Path.Combine(folder, "data"),
31
+ "-intermediateFolder", intermediateFolder,
32
+ "-o", Path.Combine(baseFolder, @"bin\test.msi")
33
+ });
34
+
35
+ result.AssertSuccess();
36
+
37
+ var output = WindowsInstallerData.Load(Path.Combine(baseFolder, "bin", "test.wixpdb"), false);
38
+ var caRows = output.Tables["CustomAction"].Rows.Single();
39
+ WixAssert.StringEqual("SetINSTALLLOCATION", caRows.FieldAsString(0));
40
+ WixAssert.StringEqual("51", caRows.FieldAsString(1));
41
+ WixAssert.StringEqual("INSTALLLOCATION", caRows.FieldAsString(2));
42
+ WixAssert.StringEqual("[INSTALLFOLDER]", caRows.FieldAsString(3));
43
+ }
44
+ }
45
+
46
+ [Fact]
47
+ public void CannotBuildWhenSetPropertyReferencesMissingAction()
48
+ {
49
+ var folder = TestData.Get("TestData", "SetProperty");
50
+
51
+ using (var fs = new DisposableFileSystem())
52
+ {
53
+ var baseFolder = fs.GetFolder();
54
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
55
+
56
+ var result = WixRunner.Execute(new[]
57
+ {
58
+ "build",
59
+ Path.Combine(folder, "CannotBuildWhenSetPropertyReferencesMissingAction.wxs"),
60
+ "-bindpath", Path.Combine(folder, "data"),
61
+ "-intermediateFolder", intermediateFolder,
62
+ "-o", Path.Combine(baseFolder, @"bin\test.msi")
63
+ });
64
+
65
+ var messages = result.Messages.Select(m => m.ToString()).ToArray();
66
+ WixAssert.CompareLineByLine(new[]
67
+ {
68
+ "The identifier 'WixAction:InstallUISequence/OnlyScheduledInExecuteSequence' could not be found. Ensure you have typed the reference correctly and that all the necessary inputs are provided to the linker."
69
+ }, messages);
70
+ }
71
+ }
72
+
73
[Fact]
74
public void CanDetectCustomActionCycle()
75
{
src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
-32
@@ -519,38 +519,6 @@ namespace WixToolsetTest.CoreIntegration
519
}
520
}
521
522
- [Fact]
523
- public void CanBuildSetProperty()
524
- {
525
- var folder = TestData.Get(@"TestData\SetProperty");
526
-
527
- using (var fs = new DisposableFileSystem())
528
- {
529
- var baseFolder = fs.GetFolder();
530
- var intermediateFolder = Path.Combine(baseFolder, "obj");
531
-
532
- var result = WixRunner.Execute(new[]
533
- {
534
- "build",
535
- Path.Combine(folder, "Package.wxs"),
536
- Path.Combine(folder, "PackageComponents.wxs"),
537
- "-loc", Path.Combine(folder, "Package.en-us.wxl"),
538
- "-bindpath", Path.Combine(folder, "data"),
539
- "-intermediateFolder", intermediateFolder,
540
- "-o", Path.Combine(baseFolder, @"bin\test.msi")
541
- });
542
-
543
- result.AssertSuccess();
544
-
545
- var output = WindowsInstallerData.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"), false);
546
- var caRows = output.Tables["CustomAction"].Rows.Single();
547
- WixAssert.StringEqual("SetINSTALLLOCATION", caRows.FieldAsString(0));
548
- WixAssert.StringEqual("51", caRows.FieldAsString(1));
549
- WixAssert.StringEqual("INSTALLLOCATION", caRows.FieldAsString(2));
550
- WixAssert.StringEqual("[INSTALLFOLDER]", caRows.FieldAsString(3));
551
- }
552
- }
553
-
522
[Fact]
523
public void CanBuildVersionIndependentProgId()
524
{
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/CannotBuildWhenSetPropertyReferencesMissingAction.wxs
new
+39
@@ -0,0 +1,39 @@
1
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2
+ <Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" Compressed="no">
3
+ <MajorUpgrade DowngradeErrorMessage="Cannot Downgrade" />
4
+
5
+ <Feature Id="ProductFeature">
6
+ <ComponentGroupRef Id="ProductComponents" />
7
+ </Feature>
8
+
9
+ <SetProperty Id="OnlyScheduledInExecuteSequence" Value="Some=Data" Before="OnlyScheduledInExecuteSequence" />
10
+ </Package>
11
+
12
+ <Fragment>
13
+ <StandardDirectory Id="ProgramFilesFolder">
14
+ <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
15
+ </StandardDirectory>
16
+ </Fragment>
17
+
18
+ <Fragment>
19
+ <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
20
+ <Component>
21
+ <File Source="test.txt" />
22
+ </Component>
23
+ </ComponentGroup>
24
+ </Fragment>
25
+
26
+ <Fragment>
27
+ <InstallExecuteSequence>
28
+ <Custom Action="OnlyScheduledInExecuteSequence" After="InstallFiles" />
29
+ </InstallExecuteSequence>
30
+ </Fragment>
31
+
32
+ <Fragment>
33
+ <CustomAction Id="OnlyScheduledInExecuteSequence" BinaryRef="PretendDll" DllEntry="IgnoredByTesting" Execute="immediate" Return="check" />
34
+ </Fragment>
35
+
36
+ <Fragment>
37
+ <Binary Id="PretendDll" SourceFile="test.txt" />
38
+ </Fragment>
39
+</Wix>