From 793a52ae8cbb8873bc23582e4c13e63d729d0bc7 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 21 Feb 2023 22:45:08 -0800 Subject: Ensure to reference the before/after WixAction when scheduling an action Fixes 7225 --- .../ExtensibilityServices/ParseHelper.cs | 23 +-------- .../CustomActionFixture.cs | 60 ++++++++++++++++++++++ .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 32 ------------ ...BuildWhenSetPropertyReferencesMissingAction.wxs | 39 ++++++++++++++ 4 files changed, 101 insertions(+), 53 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/CannotBuildWhenSetPropertyReferencesMissingAction.wxs diff --git a/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index 9046f423..9c507dff 100644 --- a/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs @@ -780,28 +780,9 @@ namespace WixToolset.Core.ExtensibilityServices Overridable = overridable, }); - if (null != beforeAction) + if (beforeAction != null || afterAction != null) { - if (WindowsInstallerStandard.IsStandardAction(beforeAction)) - { - this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), beforeAction); - } - else - { - this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, beforeAction); - } - } - - if (null != afterAction) - { - if (WindowsInstallerStandard.IsStandardAction(afterAction)) - { - this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), afterAction); - } - else - { - this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, afterAction); - } + this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), beforeAction ?? afterAction); } return actionSymbol; diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs index 035b0641..091b7d53 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs @@ -6,10 +6,70 @@ namespace WixToolsetTest.CoreIntegration using System.Linq; using WixInternal.TestSupport; using WixInternal.Core.TestPackage; + using WixToolset.Data.WindowsInstaller; using Xunit; public class CustomActionFixture { + [Fact] + public void CanBuildSetProperty() + { + var folder = TestData.Get("TestData", "SetProperty"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Package.wxs"), + Path.Combine(folder, "PackageComponents.wxs"), + "-loc", Path.Combine(folder, "Package.en-us.wxl"), + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.msi") + }); + + result.AssertSuccess(); + + var output = WindowsInstallerData.Load(Path.Combine(baseFolder, "bin", "test.wixpdb"), false); + var caRows = output.Tables["CustomAction"].Rows.Single(); + WixAssert.StringEqual("SetINSTALLLOCATION", caRows.FieldAsString(0)); + WixAssert.StringEqual("51", caRows.FieldAsString(1)); + WixAssert.StringEqual("INSTALLLOCATION", caRows.FieldAsString(2)); + WixAssert.StringEqual("[INSTALLFOLDER]", caRows.FieldAsString(3)); + } + } + + [Fact] + public void CannotBuildWhenSetPropertyReferencesMissingAction() + { + var folder = TestData.Get("TestData", "SetProperty"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "CannotBuildWhenSetPropertyReferencesMissingAction.wxs"), + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.msi") + }); + + var messages = result.Messages.Select(m => m.ToString()).ToArray(); + WixAssert.CompareLineByLine(new[] + { + "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." + }, messages); + } + } + [Fact] public void CanDetectCustomActionCycle() { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 0dd6d75f..fe9e8641 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -519,38 +519,6 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact] - public void CanBuildSetProperty() - { - var folder = TestData.Get(@"TestData\SetProperty"); - - using (var fs = new DisposableFileSystem()) - { - var baseFolder = fs.GetFolder(); - var intermediateFolder = Path.Combine(baseFolder, "obj"); - - var result = WixRunner.Execute(new[] - { - "build", - Path.Combine(folder, "Package.wxs"), - Path.Combine(folder, "PackageComponents.wxs"), - "-loc", Path.Combine(folder, "Package.en-us.wxl"), - "-bindpath", Path.Combine(folder, "data"), - "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(baseFolder, @"bin\test.msi") - }); - - result.AssertSuccess(); - - var output = WindowsInstallerData.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"), false); - var caRows = output.Tables["CustomAction"].Rows.Single(); - WixAssert.StringEqual("SetINSTALLLOCATION", caRows.FieldAsString(0)); - WixAssert.StringEqual("51", caRows.FieldAsString(1)); - WixAssert.StringEqual("INSTALLLOCATION", caRows.FieldAsString(2)); - WixAssert.StringEqual("[INSTALLFOLDER]", caRows.FieldAsString(3)); - } - } - [Fact] public void CanBuildVersionIndependentProgId() { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/CannotBuildWhenSetPropertyReferencesMissingAction.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/CannotBuildWhenSetPropertyReferencesMissingAction.wxs new file mode 100644 index 00000000..2dcff028 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/CannotBuildWhenSetPropertyReferencesMissingAction.wxs @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb