From 7c8951005e9144a35754af382727b0fb7dd600ad Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 26 Mar 2024 22:49:53 -0400 Subject: [PATCH] Allow default major upgrade to be rescheduled. Fixes https://github.com/wixtoolset/issues/issues/8046. --- .../Link/AddDefaultSymbolsCommand.cs | 6 +++++- .../DefaultMajorUpgradeReschedule.wxs | 7 +++++++ .../UpgradeFixture.cs | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/DefaultMajorUpgradeReschedule/DefaultMajorUpgradeReschedule.wxs diff --git a/src/wix/WixToolset.Core/Link/AddDefaultSymbolsCommand.cs b/src/wix/WixToolset.Core/Link/AddDefaultSymbolsCommand.cs index 28ad93513..3d5280a22 100644 --- a/src/wix/WixToolset.Core/Link/AddDefaultSymbolsCommand.cs +++ b/src/wix/WixToolset.Core/Link/AddDefaultSymbolsCommand.cs @@ -99,6 +99,7 @@ private void AddDefaultMajorUpgrade(WixPackageSymbol packageSymbol) SequenceTable = SequenceTable.InstallExecuteSequence, Action = "RemoveExistingProducts", After = "InstallValidate", + Overridable = true, }, new WixSimpleReferenceSymbol(packageSymbol.SourceLineNumbers) { @@ -126,7 +127,10 @@ private void AddSymbols(IntermediateSection section, params IntermediateSymbol[] { var symbolWithSection = new SymbolWithSection(section, symbol); var fullName = symbolWithSection.GetFullName(); - this.Find.SymbolsByName.Add(fullName, symbolWithSection); + if (!this.Find.SymbolsByName.ContainsKey(fullName)) + { + this.Find.SymbolsByName.Add(fullName, symbolWithSection); + } } } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DefaultMajorUpgradeReschedule/DefaultMajorUpgradeReschedule.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DefaultMajorUpgradeReschedule/DefaultMajorUpgradeReschedule.wxs new file mode 100644 index 000000000..3269106b9 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DefaultMajorUpgradeReschedule/DefaultMajorUpgradeReschedule.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs index 72d09b637..2d2c0703f 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs @@ -73,6 +73,20 @@ public void DefaultMajorUpgradePopulatesUpgradeRowsAsExpected() }, results); } + [Fact] + public void CanRescheduleRemoveExistingProductsWithDefaultMajorUpgrade() + { + var folder = TestData.Get("TestData", "DefaultMajorUpgradeReschedule"); + var build = new Builder(folder, new Type[] { }, new[] { folder }); + + var results = build.BuildAndQuery(Build, "InstallExecuteSequence").Where(r => r.StartsWith("InstallExecuteSequence:RemoveExistingProducts") || r.StartsWith("InstallExecuteSequence:InstallFinalize")).ToArray(); + WixAssert.CompareLineByLine(new[] + { + "InstallExecuteSequence:InstallFinalize\t\t6600", + "InstallExecuteSequence:RemoveExistingProducts\t\t6601", + }, results); + } + [Fact] public void CanOverrideDefaultMajorUpgradeLaunchConditionMessage() {