diff options
| author | Rob Mensching <rob@firegiant.com> | 2023-02-21 22:45:08 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2023-02-22 00:54:09 -0700 |
| commit | 793a52ae8cbb8873bc23582e4c13e63d729d0bc7 (patch) | |
| tree | 5853a5db45f5e2cee62a89f2eafc531015bdd7fc | |
| parent | 8ade0fbe42dcccfc551b499ce0f2608e57761be3 (diff) | |
| download | wix-793a52ae8cbb8873bc23582e4c13e63d729d0bc7.tar.gz wix-793a52ae8cbb8873bc23582e4c13e63d729d0bc7.tar.bz2 wix-793a52ae8cbb8873bc23582e4c13e63d729d0bc7.zip | |
Ensure to reference the before/after WixAction when scheduling an action
Fixes 7225
4 files changed, 101 insertions, 53 deletions
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 | |||
| 780 | Overridable = overridable, | 780 | Overridable = overridable, |
| 781 | }); | 781 | }); |
| 782 | 782 | ||
| 783 | if (null != beforeAction) | 783 | if (beforeAction != null || afterAction != null) |
| 784 | { | 784 | { |
| 785 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) | 785 | this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), beforeAction ?? afterAction); |
| 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 | } | ||
| 805 | } | 786 | } |
| 806 | 787 | ||
| 807 | return actionSymbol; | 788 | 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,11 +6,71 @@ namespace WixToolsetTest.CoreIntegration | |||
| 6 | using System.Linq; | 6 | using System.Linq; |
| 7 | using WixInternal.TestSupport; | 7 | using WixInternal.TestSupport; |
| 8 | using WixInternal.Core.TestPackage; | 8 | using WixInternal.Core.TestPackage; |
| 9 | using WixToolset.Data.WindowsInstaller; | ||
| 9 | using Xunit; | 10 | using Xunit; |
| 10 | 11 | ||
| 11 | public class CustomActionFixture | 12 | public class CustomActionFixture |
| 12 | { | 13 | { |
| 13 | [Fact] | 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] | ||
| 14 | public void CanDetectCustomActionCycle() | 74 | public void CanDetectCustomActionCycle() |
| 15 | { | 75 | { |
| 16 | var folder = TestData.Get(@"TestData"); | 76 | var folder = TestData.Get(@"TestData"); |
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 | |||
| @@ -520,38 +520,6 @@ namespace WixToolsetTest.CoreIntegration | |||
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | [Fact] | 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 | |||
| 554 | [Fact] | ||
| 555 | public void CanBuildVersionIndependentProgId() | 523 | public void CanBuildVersionIndependentProgId() |
| 556 | { | 524 | { |
| 557 | var folder = TestData.Get(@"TestData\ProgId"); | 525 | var folder = TestData.Get(@"TestData\ProgId"); |
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 @@ | |||
| 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> | ||
