Skip to Content

Major upgrades now easier than ever

I’m a fan of major upgrades, which I’ve written about before. For 10 lines of XML, you get free and easy upgrades without having to deal with the costs of patching and minor upgrades:

<! --  Major upgrade  -- >   
<Upgrade Id="$(var.UpgradeCode)">   
    <UpgradeVersion Minimum="$(var.ProductVersion)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />   
    <UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" />   

    <RemoveExistingProducts After="InstallValidate" />   

<Condition Message="!(loc.NewerVersionDetected)">   

Easy enough to cut and paste but it isn’t exactly what I would call expressive—the intent behind the code isn’t obvious, though it can be deduced fairly easily.

WiX can do better.

So, like the last time I tweaked the WiX language, it’s time for a new feature: The MajorUpgrade element encapsulates the most common options for major upgrades and creates the appropriate rows in the Upgrade and LaunchCondition tables and provides a simpler way of specifying the scheduling of the RemoveExistingProducts action. For example, here’s the simplest use:

<MajorUpgrade DowngradeErrorMessage="Can't downgrade." />

Downgrades are blocked by default, which requires you to specify a message for the launch condition message.

MajorUpgrade is a child of the Product element and automatically picks up the UpgradeCode attribute from its parent. That avoids the common duplication of the upgrade code in the Upgrade element.

MajorUpgrade has the following attributes:

<td valign="top">
  Downgrades are blocked by default.
<td valign="top">
  The launch condition message displayed when a downgrade is detected.
<td valign="top">
  Uninstall failures are upgrade failures by default.
<td valign="top">
  Manual control over the features installed in the newer product.
<td valign="top">
  Manual control over the features removed from the older product.
<td valign="top">
  When to schedule the <a href="">RemoveExistingProducts</a> action.

For details, see the MajorUpgrade element documentation. The feature ships in WiX v3.5.1315.0 and later.