问题
After getting a good answer here: WIX: How can I uninstall a previous MSI built using a VS *.vdproj, now i'm facing a different issue in the field.
I have 2 versions out there, with 2 different UpgradeCodes. That happened because we already deployed one version of the new WIX w/out syncing the UpgradeCode with the old MSI.
Syncing the new Wix installer with one of the codes, upgrade goes smoothly. Am I hosed on the second one? I tried to just uninstall the extra one from Add/Remove and that worked smoothly, but before I instruct those users to go to Add/Remove, I wanted to know if there's another trick to handle both.
Maybe if I can somehow detect during installation which version is installed, can i set the new Wix UpgradeCode dynamically?
回答1:
Put both UpgradeCodes into the Upgrade table into two separate rows. This allows you to have the MSI automatically uninstall the older MSIs during an upgrade (if that's what you want), as well as give you MSI properties to use conditionally to check what's already installed on the system.
Update (to respond to the first comment)
<!-- old product -->
<Upgrade Id="$(var.UpgradeCode1)">
<UpgradeVersion Property="OLD_PRODUCT_FOUND_1"
IncludeMaximum="yes"
Maximum="2.0.0"
MigrateFeatures="yes"
OnlyDetect="no" />
</Upgrade>
<!-- new product -->
<Upgrade Id="$(var.UpgradeCode2)">
<UpgradeVersion Property="OLD_PRODUCT_FOUND_2"
IncludeMaximum="yes"
Maximum="3.0.0"
MigrateFeatures="yes"
OnlyDetect="no" />
</Upgrade>
This code will detect both UpgradeCodes, and if one (or both) are found will remove them during the RemoveExistingProducts action.
回答2:
To detect the older version I would look into using a custom action.
来源:https://stackoverflow.com/questions/31818362/wix-when-upgrading-what-to-do-when-there-are-2-different-upgradecodes