WiX: uninstall older version of the application

Posted 遥望星空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WiX: uninstall older version of the application相关的知识,希望对你有一定的参考价值。

I have installer generated by WiX and I want it to ask: "You have already installed this app. Do you want to uninstall it?" when run. Currently it installs the app once more and uninstalls it incorrectly if there was another version installed before.

The folowing will allow you to perform an upgrade, which removes previous versions:

<?define Version = "!(bind.fileVersion.<YOUR-FILE-HERE>)" ?>
<?define UpgradeCode = "<YOUR-GUID-HERE>" ?>

<Upgrade Id="$(var.UpgradeCode)">
  <UpgradeVersion Minimum="$(var.Version)" IncludeMinimum="no" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />
  <UpgradeVersion Minimum="0.0.0" Maximum="$(var.Version)" IncludeMinimum="yes" IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallInitialize" />
  <Custom Action="NewerVersion" After="FindRelatedProducts">NEWERVERSIONDETECTED</Custom>
</InstallExecuteSequence>

<CustomAction Id="NewerVersion" Error="A later version of [ProductName] is already installed." />

You will need to define UpgradeCode and Version to suit your needs, this will also allow you to perfom an upgrade even if the version hasn‘t changed.

以上是关于WiX: uninstall older version of the application的主要内容,如果未能解决你的问题,请参考以下文章

how to install an older version of package via NuGet?

卸载 WiX 时删除文件

Wix Burn:注册表搜索失败时取消设置变量

WiX 引导程序:卸载链中的软件包

Wix卸载快捷方式无法正常工作

Nuget命令操作