在Wix中进行重大升级会在“添加/删除程序"中创建2个条目 [英] Doing Major Upgrade in Wix creates 2 entries in Add/Remove Programs
问题描述
我遵循了官方的主要升级指南而且我似乎缺少了一些东西. 这是我的 MCVE :
I've followed the official Major Upgrade guide and I seem to be missing something. Here is my MCVE:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Codepage="1252" Language="1033" Manufacturer="Bla Corporation"
Name="Bla" UpgradeCode="PUT-GUID-HERE" Version="31.00.0000">
<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" />
<MajorUpgrade AllowDowngrades="no"
AllowSameVersionUpgrades="no"
Disallow="no"
IgnoreRemoveFailure="no"
MigrateFeatures="yes"
Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed" />
<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="tenlira.ini" Guid="*">
<File Id="tenlira.ini" Source="..\ConfigurationFile\x64\tenlira.ini" KeyPath="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="TenLira" Level="1">
<ComponentRef Id="tenlira.ini" />
</Feature>
</Product>
</Wix>
它所做的只是简单地安装一个文件作为示例.到目前为止,一切都很好.现在,我要做的就是添加另一个Component
和File
,然后偏离Feature
中的相应ComponentRef
.我将Version
保留为:31.00.0000.我期望的是,新安装程序将不执行重大升级,但是可以.为什么?另外,添加/删除程序"中现在有2个条目.
All it does is simply installing a single file as an example. So far, so good. Now, all I do is add another Component
and File
and off course the corresponding ComponentRef
in Feature
. I specifically leave the Version
as is: 31.00.0000. What I expected is that the new installer will not perform a Major Upgrade, but it does. Why? Also, there is now 2 entries in Add/Remove Programs.
请帮助我找出我在这里想念的东西.谢谢.翻唱.
Please help me find out what am I missing here. Thanks. Refael.
更新:
发布问题使我再次重新阅读了文档,我发现MajorUpgrade
元素中的AllowSameVersionUpgrades
thingy应该设置为yes
.这次,添加/删除程序"中只有一个主菜,但它仍执行主要升级".为什么?
UPDATE:
Posting the question got me to reread the documentation again and I discovered that the AllowSameVersionUpgrades
thingy in the MajorUpgrade
element should be set to yes
. This time there is only one entree in the Add/Remove Programs, but it still performs Major Upgrade. Why?
推荐答案
主要升级-旧的手动方式"
我想通过组合auto-generated product GUID
,AllowSameVersionUpgrades
设置为yes
并保持version number
不变,您可能遇到了WiX MajorUpgrade元素可能无法完全处理的怪问题.
Major Upgrade - "The Old, Manual Way"
I guess you are hitting an oddity that may not be handled entirely as expected by the WiX MajorUpgrade element by combining the auto-generated product GUID
, the AllowSameVersionUpgrades
set to yes
and keeping the version number
the same.
在WiX的 MajorUpgrade元素 -我可能会误会,可能是我不知道的一种方式.对于它的价值,我不太愿意允许相同版本的升级".
I can't see any obvious way to set the MinInclusive attribute in WiX's MajorUpgrade element - I could be mistaken, there might be a way I am unaware of. For what it is worth, I am not too keen on allowing "same version upgrades".
但是,您可以尝试"使用旧方法"来编写 升级版本. MajorUpgrade元素本质上是要设置的便利"功能轻松进行重大升级,我相信它适用于大多数用户. Bob Arnson的博客解释了引入MajorUpgrade元素.该博客还显示了一个示例,说明如何使用较旧的元素" Upgrade
和UpgradeVersion
手动"执行操作(请检查一下).
However, you could try to "use the old way" to author the Upgrade table using the "older elements" Upgrade and UpgradeVersion. The MajorUpgrade element is essentially a "convenience" feature to set up your major upgrades easily, and I believe it works for most users. Bob Arnson has a blog explaining the introduction of the MajorUpgrade element. This blog also shows a sample of how to do things "manually" with the "older elements" Upgrade
and UpgradeVersion
(do check it out).
我做了一个快速的模型,可以做您想做的,这只是一个草稿",无法做出任何保证.我使用预处理器定义来设置一些可以在WiX源文件-作为C ++开发人员,这对您来说是小菜一碟,因此我不会浪费时间对其进行解释-该源应该有意义:
I made a quick mock-up that might do what you want, it is just a "rough draft" - can't make any guarantees. I use preprocessor defines to set some variables that can be referenced in the WiX source file - as a C++ developer this is a piece of cake for you so I won't waste time explaining it - the source should make sense:
<?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
文件夹中.
Now the !(loc.NewerVersionDetected)
has to be explained. This is a localized string (for delivering your setup in different languages). To use it, right click your WiX project in Visual Studio and go: Add New Item... => Localization File => Add
. As the localization file is added, your output MSI will also now go into a en-us
folder under your main output location (Debug or Release).
在本地化文件中,添加:
In the localization file, add:
<?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>
现在您应该能够在此文件中添加新的字符串,并使用这些语言文件轻松转换整个设置.
And you should now be able to add new strings to this file and easily translate your whole setup using such language files.
还添加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
.
Also add the WiX GUI extension. Right click "References". Add Reference... => Browse to WixUIExtension.dll => Double click this file, and press OK
. Normal folder to find the file is: C:\Program Files (x86)\WiX Toolset v3.11\bin
.
我只想提一下,INI文件最好通过文件表(该文件被视为常规文件,要么覆盖整个现有文件,要么将其保留在原位-不强制执行任何新值).与MSI IniFile表相对应的WiX元素自然是 IniFile元素.
I just want to mention that INI files should ideally be installed via the IniFile table (entries are treated as atomic key-value pairs allowing advanced merging of keys and values for existing INI files), and not via the File table (the file is treated as a regular file either overwriting the whole existing file or leaving it in place - not enforcing any new values). The WiX element corresponding to the MSI IniFile table is naturally the IniFile element.
一个临时样本:
<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>
链接 :
Links:
这篇关于在Wix中进行重大升级会在“添加/删除程序"中创建2个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!