在工作中,我们使用WiX来构建安装包。我们希望产品X的安装会导致该机器上该产品以前版本的卸载。

我已经在互联网上的几个地方读到一个重大升级,但不能让它工作。 任何人可以指定我需要采取的确切步骤,以添加卸载以前版本的功能到WiX?


当前回答

下面的内容对我很有用。

<Product Id="*" Name="XXXInstaller" Language="1033" Version="1.0.0.0" 
    Manufacturer="XXXX" UpgradeCode="YOUR_GUID_HERE">
<Package InstallerVersion="xxx" Compressed="yes"/>
<Upgrade Id="YOUR_GUID_HERE">
    <UpgradeVersion Property="REMOVINGTHEOLDVERSION" Minimum="1.0.0.0" 
        RemoveFeatures="ALL" />
</Upgrade>
<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

请确保“产品”中的“升级码”与“升级”中的“Id”匹配。

其他回答

我使用这个网站来帮助我了解有关WiX升级的基础知识:

http://wix.tramontana.co.hu/tutorial/upgrades-and-modularization

之后,我创建了一个示例安装程序(安装了一个测试文件),然后创建了升级安装程序(安装了2个示例测试文件)。这将使你对该机制的工作原理有一个基本的了解。

正如Mike在Apress的书中所说,“Windows安装程序的权威指南”,它会帮助你理解,但它不是用WiX写的。

另一个非常有用的网站是这个:

http://www.wixwiki.com/index.php?title=Main_Page

以下是我用于主要升级的语法:

<Product Id="*" UpgradeCode="PUT-GUID-HERE" Version="$(var.ProductVersion)">
 <Upgrade Id="PUT-GUID-HERE">
    <UpgradeVersion OnlyDetect="yes" Minimum="$(var.ProductVersion)" Property="NEWERVERSIONDETECTED" IncludeMinimum="no" />
    <UpgradeVersion OnlyDetect="no" Maximum="$(var.ProductVersion)" Property="OLDERVERSIONBEINGUPGRADED" IncludeMaximum="no" />
</Upgrade>

<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

正如@Brian Gillespie指出的,根据所需的优化,还有其他地方可以安排RemoveExistingProducts。注意,PUT-GUID-HERE必须相同。

这对我来说很管用,即使我的主要成绩是DOWN:

<Wix ...>
  <Product ...>
    <Property Id="REINSTALLMODE" Value="amus" />
    <MajorUpgrade AllowDowngrades="yes" />

下面的内容对我很有用。

<Product Id="*" Name="XXXInstaller" Language="1033" Version="1.0.0.0" 
    Manufacturer="XXXX" UpgradeCode="YOUR_GUID_HERE">
<Package InstallerVersion="xxx" Compressed="yes"/>
<Upgrade Id="YOUR_GUID_HERE">
    <UpgradeVersion Property="REMOVINGTHEOLDVERSION" Minimum="1.0.0.0" 
        RemoveFeatures="ALL" />
</Upgrade>
<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

请确保“产品”中的“升级码”与“升级”中的“Id”匹配。

我从教程中漏掉了一件重要的事情(从http://www.tramontana.co.hu/wix/lesson4.php偷来的),导致“此产品的另一个版本已经安装”错误:

*Small updates mean small changes to one or a few files where the change doesn't warrant changing the product version (major.minor.build). You don't have to change the Product GUID, either. Note that you always have to change the Package GUID when you create a new .msi file that is different from the previous ones in any respect. The Installer keeps track of your installed programs and finds them when the user wants to change or remove the installation using these GUIDs. Using the same GUID for different packages will confuse the Installer.

次要升级表示产品版本已经更改的更改。修改Product标签的Version属性。产品将保持不变,因此您不需要更改product GUID,当然,需要获得一个新的Package GUID。

主要升级是指从一个完整版本到另一个完整版本的重大变化。更改所有内容:版本属性、产品和包guid。