wix - 在 Wix 中进行重大升级会在添加/删除程序中创建 2 个条目

标签 wix windows-installer major-upgrade

我遵循了官方的 Major Upgrade 指南,但似乎遗漏了一些东西。
这是我的 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>

它所做的只是安装单个文件作为示例。到现在为止还挺好。现在,我要做的就是添加另一个 ComponentFile ,当然还有 ComponentRef 中相应的 Feature 。我特别保留 Version 原样:31.00.0000。我期望新安装程序将 而不是 执行主要升级,但确实如此。为什么?此外,添加/删除程序中现在有 2 个条目。

请帮我找出我在这里遗漏了什么。谢谢。雷法尔。

更新 :
发布问题让我再次重新阅读文档,我发现 AllowSameVersionUpgrades 元素中的 MajorUpgrade 应该设置为 yes 。这次添加/删除程序中只有一个主项,但它仍然执行Major Upgrade。为什么?

最佳答案

更新 :这是一个列表,通过识别最常见的问题来帮助调试失败的主要升级:Common causes of failed major upgrades

重大升级 - “旧的手动方式”
我猜您遇到了一个奇怪的问题,通过组合 auto-generated product GUID ,将 AllowSameVersionUpgrades 设置为 yes 并保持 version number 相同,WiX MajorUpgrade 元素可能无法完全按照预期处理。
我看不到在 WiX 的 MajorUpgrade element 中设置 MinInclusive 属性的任何明显方法 - 我可能弄错了,可能有一种我不知道的方法。就其值(value)而言,我不太热衷于允许“相同版本升级”。
但是,您可以尝试“ 使用旧方式 ”来使用“旧元素” Upgrade tableUpgrade 创作 UpgradeVersionMajorUpgrade element 本质上是一个“便利”功能,可以轻松设置您的主要升级,我相信它适用于大多数用户。 Bob Arnson has a blog explaining the introduction of the MajorUpgrade element 。此博客还展示了如何使用“旧元素”UpgradeUpgradeVersion“手动”执行操作的示例(请查看)。
我做了一个快速的模型,可能会做你想做的,它只是一个“草稿” - 不能做任何保证。我使用 preprocessor defines 来设置一些可以在 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 table 安装(条目被视为原子键值对,允许高级合并现有 INI 文件的键和值),而不是通过 File table(文件被视为常规文件要么覆盖整个现有文件,要么将其留在原地 - 不强制执行任何新值)。 MSI IniFile 表对应的 WiX 元素自然是 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>

链接 :
  • Adding entries to MSI UpgradeTable to remove related products
  • 关于wix - 在 Wix 中进行重大升级会在添加/删除程序中创建 2 个条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48745912/

    相关文章:

    wix - 在 WiX 中为每用户或每机器安装上下文设置 ALLUSERS

    deployment - 如何部署包含版本低于已部署文件的文件的产品升级?

    wpf - 编写 WPF Wix 安装程序

    Wix - 根据权限更改安装文件夹

    WiX:在 wxs-fragment-file 中不可用的包含文件中定义

    WiX 为 NetworkService 设置 App_Data 文件夹权限修改

    c# - 在 CustomActions 类中设置项目窗口处理程序

    wix - MSI引用计数:两种产品安装相同的MSI

    wix - Majorupgrade 或 Upgrade ID 哪个是主要升级的首选?