Wix MajorUpgrade problems

2020-02-28 06:25发布

问题:

Here're the scenarios.

1.) Install 1.0.1.1 then upgrade to 1.0.2.2 ===> This works well (as expected)

2.) Install 1.0.2.2 then downgrade to 1.0.1.1 ===> This doesn't work (as expected)

3.) Install 1.0.1.1 then install 1.0.1.1 ===> This goes into Repair/Remove mode (as expected)

4.) Install 1.0.1.1 then install 1.0.1.2 ===> It is installed like a new one and show the program twice in Add/Remove program in control panel (I suppose it should work like 3.) because, from my understanding, MSI doesn't care the 4th part of product version)

Am I doing anything wrong ?

<Product Id="*" Name="My product" Version="$(var.Version)" Language="1033"  Manufacturer="My Company" UpgradeCode="MY-UPGRADE-CODE">

<Package Description="My product" Comments="Comments" InstallerVersion="200" Compressed="yes" />

<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

回答1:

This is behaving as mentioned in the WIX documentation. You need to set the below property to "Yes" in the MajorUpgrade element to handle this scenario. Read the highlighted text for more details.

AllowSameVersionUpgrades (YesNoType)

When set to no (the default), installing a product with the same version and upgrade code (but different product code) is allowed and treated by MSI as two products. When set to yes, WiX sets the msidbUpgradeAttributesVersionMaxInclusive attribute, which tells MSI to treat a product with the same version as a major upgrade.

This is useful when two product versions differ only in the fourth version field. MSI specifically ignores that field when comparing product versions, so two products that differ only in the fourth version field are the same product and need this attribute set to yes to be detected.

Note that because MSI ignores the fourth product version field, setting this attribute to yes also allows downgrades when the first three product version fields are identical. For example, product version 1.0.0.1 will "upgrade" 1.0.0.2998 because they're seen as the same version (1.0.0). That could reintroduce serious bugs so the safest choice is to change the first three version fields and omit this attribute to get the default of no.

This attribute cannot be "yes" when AllowDowngrades is also "yes" -- AllowDowngrades already allows two products with the same version number to upgrade each other.

Source: WIX Documentation