【发布时间】:2016-07-06 12:34:12
【问题描述】:
我正在尝试允许升级我的应用程序。如果用户安装 1.0.0,那么下次我发布一个版本时,我可以给他们 1.1.0,他们可以安装它。 Overwriting | removing | replacing the first version 控制面板中应该只安装一个版本 -> 卸载或更改程序。
我的问题是:
如果我没有设置产品 ID 等于 *(使用 $(var.ProductId)" 代替)我得到 p>
已安装此产品的另一个版本。安装 此版本无法继续...
如果我将其设置为 *,那么它会安装新版本,并且我安装了两个版本。
我创建了一个简单的 wix 应用程序来测试它。
<?xml version="1.0" encoding="UTF-8"?>
<?define ProductVersion="!(bind.FileVersion.MyAssemblyDll)"?>
<?define UpgradeCode="f4d7f199-28f6-45d5-ad99-7c62938274be"?>
<?define ProductId="{6408D956-40DA-4AEE-883E-5425F1562004}"?>
<?define Version="1.2.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="$(var.ProductId)" Name="UpgradeTest" Language="1033" Version="$(var.Version)" Manufacturer="xxx" UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<!-- prevents down gradeing -->
<!-- one upgrade installes new version first then removes the old one. -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallExecute"/>
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="UpgradeTest" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="UpgradeTest" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent">
<File Id="Product.wxs" Source="Product.wxs" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
我已经尝试让这个工作好几天了,我已经用尽了所有的教程,可以追溯到 2008 年。任何帮助将不胜感激。
更新:
<MajorUpgrade AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="no" />
不好:在控制面板中产生两个版本。
更新二:
<Upgrade Id ="$(var.ProductUpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductFullVersion)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Maximum="$(var.ProductFullVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
<Condition Message="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features.">Not NEWERVERSIONDETECTED</Condition>
不好:在控制面板中产生两个版本。
【问题讨论】: