Skip to content

Commit

Permalink
Allow default major upgrade to be rescheduled.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnson committed Mar 27, 2024
1 parent 8db3616 commit 2b6fa3a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/wix/WixToolset.Core/Link/AddDefaultSymbolsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void AddDefaultMajorUpgrade(WixPackageSymbol packageSymbol)
SequenceTable = SequenceTable.InstallExecuteSequence,
Action = "RemoveExistingProducts",
After = "InstallValidate",
Overridable = true,
},
new WixSimpleReferenceSymbol(packageSymbol.SourceLineNumbers)
{
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="DefaultMajorUpgradeReschedule" Language="1033" Version="2.0.0" Manufacturer="Example Corporation" UpgradeCode="{3F2494B1-AF5E-48ED-9C9E-843F1DB2BC97}">
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
</Package>
</Wix>
14 changes: 14 additions & 0 deletions src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 2b6fa3a

Please sign in to comment.