我们在Wix Packages.wxs文件中使用以下代码,根据文档,我们更改了UpgradeCode GUID和版本号。从1.0.1.0到1.0.2.0,但是当我们构建并尝试安装msi软件包时,它说仍然安装了旧版本,因此我们需要先卸载它才能继续。
<Product Id="8B3DFDFF-D894-4A31-AA92-824729385F15" Name="WixCodeBase" Language="1033" Version="1.0.2.0" Manufacturer="Company Name" UpgradeCode="C78D9362-A156-44A2-94D0-AFA19389FFE8">
<Package Id="*" Keywords="Installer" Manufacturer="Company Name" Description="Wix Installer" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade Schedule ="afterInstallValidate" AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id='1' Cabinet='WixPackage.cab' EmbedCab='yes' />
答案 0 :(得分:3)
对于重大升级,请更改Product
元素的Id
属性而不是UpgradeCode
属性。实际上,UpgradeCode
属性必须在各个版本中保持不变,才能使用MajorUpgrade
元素。 MSDN has all the details。
答案 1 :(得分:0)
我维护着一个名为IsWiX的开源项目,该项目提供了模板和设计器来加速WiX / MSI的学习和开发过程。这些模板提供的许多现成功能之一就是提供适当的重大升级支持。考虑以下由模板生成的代码:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--
MSIProductVersion is defined in DesktopApplication.wixproj as 0.0.1 for local desktop builds.
You should pass in the MSBuild Property 'MSIProductVersion' to override it during an automated build.
See http://msdn.microsoft.com/en-us/library/windows/desktop/aa370859%28v=vs.85%29.aspx for information on allowable values.
The Product@Id attribute (ProductCode Property) will be a random GUID for each build. This is to support "Major Upgrades" where each install
is a seamless uninstall/reinstall.
-->
<Product Id="*" Name="DesktopApplication" Language="1033" Version="$(var.MSIProductVersion)" Manufacturer="DesktopApplication" UpgradeCode="7220a19b-ed49-4cd1-8002-6af7926441b4">
<Package InstallerVersion="301" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes" />
<!-- Major Upgrade Rule to disallow downgrades -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--Common Launch Condition-->
<!-- Examples at http://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html -->
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message="[ProductName] requires .NET Framework 4.0.">Installed OR NETFRAMEWORK40FULL</Condition>
<!-- Include User Interface Experience -->
<Icon Id="Icon.ico" SourceFile="Resources\Icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="Icon.ico"></Property>
<UIRef Id="UI"/>
<!-- Include Features and Directories Fragment -->
<DirectoryRef Id="INSTALLLOCATION"/>
</Product>
</Wix>
除了在注释中进行记录外,它还在tutorials中进行了讨论。
简而言之,您需要保持UpgradeCode不变,并随机分配ProductCode。