更新:这是一个列表,通过识别最常见的问题来帮助调试失败的主要升级:主要升级失败的常见原因
重大升级 - “旧的手动方式”
我猜你遇到了一个奇怪的问题,WiX MajorUpgrade 元素可能无法完全按照预期通过将auto-generated product GUID
、AllowSameVersionUpgrades
设置为yes
并保持version number
相同来处理。
我看不到在 WiX 的MajorUpgrade 元素中设置 MinInclusive 属性的任何明显方法——我可能弄错了,可能有一种我不知道的方法。对于它的价值,我不太热衷于允许“相同版本升级”。
但是,您可以尝试“使用旧方法”使用“旧元素” Upgrade和UpgradeVersion 创建Upgrade 表。MajorUpgrade元素本质上是一种“方便”功能,可以轻松设置您的主要升级,我相信它适用于大多数用户。Bob Arnson 有一个博客解释了 MajorUpgrade 元素的引入。该博客还展示了如何使用“旧元素”“手动”执行操作的示例,并且(请检查一下)。Upgrade
UpgradeVersion
我做了一个快速的模型,可以做你想要的,它只是一个“草稿”——不能做任何保证。我使用预处理器定义来设置一些可以在 WiX 源文件中引用的变量——作为 C++ 开发人员,这对你来说是小菜一碟,所以我不会浪费时间解释它——源代码应该是有意义的:
<?define MyProductVersion = "31.00.0000" ?>
<?define MyProductCode = "PUT-GUID-HERE" ?>
<?define MyUpgradeCode = "PUT-GUID-HERE" ?>
<!--Recommendation: set a path variable that you can redirect at will to a new release folder (new build output folder): -->
<!-- <?define MyBasePath = "C:\Projects\MyApp\Release\31.00.0000\" ?> -->
<!-- SAMPLE:
<Component Win64="yes" Feature="MainApplication">
<File Source="$(var.MyBasePath)\myapp.exe" />
</Component> -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="$(var.MyProductCode)" Codepage="1252" Language="1033" Manufacturer="Bla Corporation"
Name="Bla" UpgradeCode="$(var.MyUpgradeCode)" Version="$(var.MyProductVersion)">
<Package Comments="Contact: Refael Sheinker, refael.sheinker@bla.com." Description="Bla"
InstallerVersion="500"
Compressed="yes"
InstallScope="perMachine"
Keywords="Installer,MSI,Database" Languages="1033" Manufacturer="Bla Corporation" Platform="x64" />
<Media Id="1" Cabinet="my_application.cab" EmbedCab="yes" />
<!-- Major upgrade -->
<Upgrade Id="$(var.MyUpgradeCode)">
<!-- Downgrade Protection -->
<UpgradeVersion Minimum="$(var.MyProductVersion)" OnlyDetect="yes" IncludeMinimum="yes" Property="DOWNGRADE_DETECTED" />
<!-- Major Upgrade Configuration -->
<UpgradeVersion IncludeMinimum="no" Maximum="$(var.MyProductVersion)" IncludeMaximum="no" MigrateFeatures="yes" Property="UPGRADE_DETECTED" />
</Upgrade>
<!-- Major Upgrade: Schedule RemoveExistingProducts -->
<InstallExecuteSequence>
<!-- Potential scheduling (after): InstallValidate, InstallInitialize, InstallExecute, InstallExecuteAgain, InstallFinalize -->
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
<!--Launch Condition: Abort setup if higher version found-->
<Condition Message="!(loc.NewerVersionDetected)">
NOT DOWNGRADE_DETECTED
</Condition>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONROOTDIRECTORY" />
<UIRef Id="WixUI_InstallDir" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="PROGRAMFILESSUBDIR" Name="Bla">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="BlaInternal" />
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="Test.ini" Guid="PUT-GUID-HERE" Win64="yes" Feature="MainApplication">
<CreateFolder Directory="APPLICATIONROOTDIRECTORY" />
<IniFile Id="SomeSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting1" Name="Test.ini" Section="MySection" Value="Some Setting" />
<IniFile Id="OtherSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting2" Name="Test.ini" Section="MySection" Value="Other Setting" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="TenLira" Level="1">
<!--<ComponentRef Id="tenlira.ini" />-->
</Feature>
</Product>
</Wix>
现在!(loc.NewerVersionDetected)
必须解释一下。这是一个本地化字符串(用于以不同语言提供您的设置)。要使用它,请在 Visual Studio 中右键单击您的 WiX 项目并转到:Add New Item... => Localization File => Add
. 添加本地化文件后,您的输出 MSI 现在也将进入en-us
主输出位置(调试或发布)下的文件夹。
在本地化文件中,添加:
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="NewerVersionDetected">A later version of [ProductName] is already installed.</String>
</WixLocalization>
您现在应该能够向该文件添加新字符串,并使用此类语言文件轻松翻译您的整个设置。
还要添加 WiX GUI 扩展。Right click "References". Add Reference... => Browse to WixUIExtension.dll => Double click this file, and press OK
. 找到文件的普通文件夹是:C:\Program Files (x86)\WiX Toolset v3.11\bin
.
INI 文件
我只想提一下,INI 文件最好通过IniFile 表安装(条目被视为原子键值对,允许高级合并现有 INI 文件的键和值),而不是通过File 表(文件被处理作为常规文件,要么覆盖整个现有文件,要么将其保留在原位 - 不强制执行任何新值)。MSI IniFile 表对应的 WiX 元素自然是IniFile 元素。
临时样本:
<Component Id="Test.ini" Guid="PUT-GUID-HERE" Win64="yes" Feature="MainApplication">
<CreateFolder Directory="APPLICATIONROOTDIRECTORY" />
<IniFile Id="SomeSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting1" Name="Test.ini" Section="MySection" Value="Some Setting" />
<IniFile Id="OtherSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting2" Name="Test.ini" Section="MySection" Value="Other Setting" />
</Component>
链接: