使用wix安装较新版本的msi时,从程序和功能中删除程序

时间:2014-03-19 11:37:22

标签: wix windows-installer

我正在使用WIX创建我的安装程序msi。 当我安装较新版本的应用程序时,我的旧应用程序已经安装在机器上,然后删除所有文件和旧版本的程序集并放置较新的版本文件和程序集,但在控制面板的程序和功能中显示旧版本和新版本。 / p>

我正在使用以下代码进行升级

 <Upgrade Id="$(var.UpgradeCode)">
  <UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="!(loc.lcid)" Property="NEWPRODUCTFOUND"/>
  <UpgradeVersion Minimum="1.0.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Language="!(loc.lcid)" Property="UPGRADEFOUND"/>
</Upgrade>

 <CustomAction Id="PreventDowngrading" Error="!(loc.CustomAction_PreventDowngrading)"/>

<InstallUISequence>
  <Custom Action="SetWindowsTypeProp" Before="FindRelatedProducts">1</Custom>
  <!--Custom Action="SetPresenceProperties" After="SetWindowsTypeProp">1</Custom-->
  <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
</InstallUISequence>


<InstallExecuteSequence>
  <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
  <RemoveExistingProducts Before="InstallInitialize"/>
</InstallExecuteSequence>

请帮我解决如何从程序和功能中删除条目

1 个答案:

答案 0 :(得分:3)

这意味着您的MajorUpgrade无效。 FindRelatedProducts找不到旧版本,因此REmoveExistingProducts无效。对于最新版本的WiX,您可以删除大量此代码并将其替换为较新的MajorUpgrade元素。它是一种更高级别的抽象,简化了大部分创作。

为了取得成功的MajorUpgrade,必须要做好几件事:

1)旧的和新的MSI必须具有相同的UpgradeCode GUID。 (虽然技术上MSI可以通过使用额外的UpgradeCode属性来删除不相关的产品,但我们会忽略这个问题。)

2)旧的和新的MSI必须具有唯一的ProductCode GUID。

3)新的MSI必须具有更高版本的ProductVersion属性。请注意,仅评估前3个数字。 (1.2.3 - > 1.2.4工作1.2.3.4 - &gt; 1.2.3.5不工作)

4)旧的MSI和新的MSI必须安装在相同的上下文中(每个用户 - >每个用户或每台机器 - >每台机器)

5)升级表必须正确编写。使用MajorUpgrade元素来帮助解决这个问题。