如何让 WiX 主要升级工作? [英] How to get WiX major upgrade working?
问题描述
我正在努力启用 WiX 中的主要升级功能.
I am struggling to enable the major upgrade functionality in WiX.
我希望安装程序的每个新版本都是一次重大升级(完全卸载,然后重新安装),因为我们不希望有不同的升级和全新安装版本.
I want every new version of the installer to be a major upgrade (full uninstall, then new install) as we don't want different upgrade and clean install versions.
我开始尝试使用标签内容来执行此操作,但我一直收到已安装另一个版本"的消息.运行安装程序时出现错误消息.
I started off trying to do it using the tag stuff, but I kept getting "Another version is installed." error message when I run the installer.
所以我实现了在 V3.5 中添加的新标签,以使升级更容易.我仍然收到错误消息.
So I implemented the new tag that was added in V3.5 to make upgrades easier. I was still getting the error message.
然后我在某处读到您需要为每个新版本更改 ID GUID.所以我设置了 Id="*" 来让 WiX 生成它们.
I then read somewhere that you need to change the Id GUID for each new version. So I set Id="*" to get WiX to generate them.
现在,当我安装新版本时,它不会卸载旧版本,并且您最终会在同一文件夹中安装两次.我解决了这个问题,因为运行 MSI(新的或旧的)都会显示修复/删除屏幕.
Now when I install the newer version it doesn't uninstall the older version, and you end up with two installations to the same folder. I worked this out because running either MSI (new or old) would bring up the repair/remove screen.
而且程序也没有被新版本覆盖.
Also the program was not overwritten with the new version.
这是我的 WiX 脚本的开始:
Here is the start of my WiX script:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="Foo"
Language="1033"
Codepage="1252"
Version="!(bind.FileVersion.Foo.exe)"
Manufacturer="Foo Bar Ltd."
UpgradeCode="dac2fab2-7d76-4e47-b25f-0748380dab81">
<Package
Description="Foo"
Comments="This installer database contains the logic and data required to install Foo."
InstallerVersion="300"
Languages="1033"
SummaryCodepage="1252"
Platform="x86"
Compressed="yes" />
<!-- Remove older versions -->
<!-- Important note: MSI ignores the last version digit 1.0.0.? when comparing versions, so always change at least the 3rd digit for new external releases-->
<MajorUpgrade DowngradeErrorMessage="The version currently installed is newer than the version you are attempting to install."/>
推荐答案
这是我用于所有软件包的片段,经过许多内部和公开版本的改进
Here's a snippet of what I use for all my packages, refined over many internal and public releases
<Product Id="*"
UpgradeCode="$(var.Property_UpgradeCode)"
Name="!(loc.ApplicationName)"
Language="!(loc.Property_ProductLanguage)"
Version="$(var.version)"
Manufacturer="!(loc.ManufacturerName)" >
<Package Description="!(loc.Package_Description) $(var.version)"
Comments="!(loc.Package_Comments)"
Manufacturer="!(loc.ManufacturerName)"
InstallerVersion="301"
Compressed="yes"
InstallPrivileges="elevated"
InstallScope="perMachine"
Platform="$(var.ProcessorArchitecture)" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Upgrade Id="$(var.Property_UpgradeCode)">
<UpgradeVersion OnlyDetect="yes"
Minimum="$(var.version)"
Property="NEWERVERSIONDETECTED"
IncludeMinimum="no" />
<UpgradeVersion OnlyDetect="no"
Maximum="$(var.version)"
Property="OLDERVERSIONBEINGUPGRADED"
IncludeMaximum="no" />
<!-- Detect for changes in 4th field only -->
<UpgradeVersion Property="ANOTHERBUILDINSTALLED"
Maximum="$(var.version)" Minimum="$(var.version)"
IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="yes" />
</Upgrade>
<CustomAction Id="CA_BlockOlderVersionInstall" Error="!(loc.LaunchCondition_LaterVersion)" />
<CustomAction Id="CA_BlockAnotherBuildInstall" Error="!(loc.LaunchCondition_AnotherBuild)" />
<InstallExecuteSequence>
<Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
<![CDATA[NEWERVERSIONDETECTED]]>
</Custom>
<!-- Prevent installation on 4th version field change only -->
<Custom Action="CA_BlockAnotherBuildInstall" After="FindRelatedProducts">
<![CDATA[ANOTHERBUILDINSTALLED]]>
</Custom>
<LaunchConditions After="AppSearch" />
<!-- Schedule RemoveExistingProducts early -->
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
<![CDATA[NEWERVERSIONDETECTED]]>
</Custom>
<!-- Prevent installation on 4th version field change only -->
<Custom Action="CA_BlockAnotherBuildInstall" After="FindRelatedProducts">
<![CDATA[ANOTHERBUILDINSTALLED]]>
</Custom>
<LaunchConditions After="AppSearch" />
</InstallUISequence>
<!-- .... -->
</Product>
这篇关于如何让 WiX 主要升级工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!