Wix 安装程序有选择地卸载以前的版本

Wix installer selectively uninstall previous versions

我有一个wix安装程序,用于安装不同版本的软件。允许并行安装相同的软件(不同版本)。 wix产品代码是'*'所以它总是一个重大升级。

现在,我需要选择性地卸载以前版本的软件。为此,我在 UpgradeVersion 标签中定义了版本范围?

<Upgrade Id="ID">
  <UpgradeVersion  Minimum="0.0.0.0" Maximum="0.5.0.0" IncludeMinimum="yes" IncludeMaximum="no" Property="FORCEREMOVEOLDVERSION" />
  <UpgradeVersion  Minimum="0.6.0.0" Maximum="0.7.0.0" IncludeMinimum="yes" IncludeMaximum="yes" Property="SELECTIVELY_UNINSTALL" />
  <UpgradeVersion  Minimum="0.8.0.0" Maximum="1.5" IncludeMinimum="yes" IncludeMaximum="yes" Property="OLDERVERSIONDETECTED" />
</Upgrade>

这非常有效。但是,当我必须有选择地卸载范围 0.6 - 0.7 时,我该如何执行此操作,因为只有一个 RemoveExistingProducts 标签。

<InstallExecuteSequence>
    <RemoveExistingProducts Overridable="no"  Before="InstallInitialize" /> 
</InstallExecuteSequence>

能否请您提出可能的方法来检查 'SELECTIVELY_UNINSTALL' 标志并删除范围 (0.6-0.7),同时自动删除其他以前的版本?

谢谢。

我从来没有借此机会亲自验证过这一点,但应该有一种非常直接的方法来处理这个问题。要理解它,首先你必须理解 FindRelatedProducts and RemoveExistingProducts 是做什么的。键在 FindRelatedProducts 的第二句和 RemoveExistingProducts 的第一句中:

When FindRelatedProducts detects a correspondence between the upgrade information and an installed product, it appends the product code to the property specified in the ActionProperty column of the UpgradeTable.

The RemoveExistingProducts action goes through the product codes listed in the ActionProperty column of the Upgrade table and removes the products in sequence by invoking concurrent installations.

鉴于您希望始终删除在 FORCEREMOVEOLDVERSIONOLDERVERSIONDETECTED 中找到并存储的任何先前版本,但有条件地删除在 SELECTIVELY_UNINSTALL 中找到并存储的任何版本,您只需做的是有条件地清除属性SELECTIVELY_UNINSTALL。在更复杂的情况下,您甚至可以解析存储在 ActionProperty 引用的 属性 中的产品代码列表,并仅删除其中的一些。

请注意,这不允许您通过向操作 属性 添加产品代码来解决 ALLUSERS 必须匹配的要求。