无法删除MSI的早期版本。在控制面板中显示多个条目

时间:2019-05-23 19:35:46

标签: windows wix windows-installer

我不确定我是否缺少某些东西,或者我只是傻瓜,这与卸载MSI有关。基本上,我正在构建一个应用程序,并使用WIX创建MSI安装程序。发生的是,我能够安装该应用程序的先前版本,但无法升级到较新版本的MSI。例如,当我单击/安装较新版本的MSI,然后单击较旧的MSI时,将同时安装两个MSI并在控制面板(MyApp 1.5.0,MyApp 1.6.0)中可见。

我非常确定我已经正确配置了“ MINORUPGRADE / MAJORUPGRADE”以及RemoveExistingProducts操作,但是此问题仍然会发生。

我尝试修改MINORUPGRADE / MAJORUPGRADE值和RemoveExistingProducts属性,但是仍然得到相同的行为。

我的WIX配置看起来像这样(没有目录/路径...)

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*" Language="1033" Manufacturer="MyApp" Name="MyApp $(env.APP_BASE_VERSION)" UpgradeCode="$(env.UPGRADE_CODE)"
    Version="$(env.APP_BASE_VERSION)">
    <Package Compressed="yes" InstallerVersion="200" InstallScope="perMachine" InstallPrivileges="elevated" Description="MyApp $(env.APP_VERSION) Installer"
      Comments="" Manufacturer="MyApp" />

    <Property Id="MsiLogging" Value="v!" />
    <MediaTemplate EmbedCab="yes" CompressionLevel="$(env.COMPRESSION_LEVEL)"/>
    <Icon Id="icon.ico" SourceFile="$(env.STATIC_RESOURCE_PATH)\icon.ico" />
    <Property Id="ARPPRODUCTICON" Value="icon.ico" />

    <Upgrade Id="$(env.UPGRADE_CODE)">
      <UpgradeVersion 
          Property="MAJORUPGRADE" 
          Minimum="0.0.0.0" 
          IncludeMinimum="yes" 
          Maximum="$(env.APP_BASE_VERSION)" 
          IncludeMaximum="no" 
          IgnoreRemoveFailure="no" 
          MigrateFeatures="yes" /> 
        <UpgradeVersion 
          Property="MINORUPGRADE" 
          Maximum="$(env.APP_BASE_VERSION)" 
          Minimum="$(env.APP_BASE_VERSION)" 
          IncludeMinimum="yes" 
          IncludeMaximum="yes" 
          /> 

    </Upgrade>  


    ...

    <CustomAction Id="Remove_Roaming_MyApp" Directory="TARGETDIR" ExeCommand="cmd.exe /C &quot;rmdir /s /q &quot;[AppDataFolder]\MyApp&quot;&quot;" Execute="deferred" Return="ignore" HideTarget="yes" Impersonate="no" />

    <Property Id="WixShellExecTarget" Value="[#MyAppEXE]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

    <util:CloseApplication Id="CloseApp"  Target="MyApp.exe" RebootPrompt="no" CloseMessage="yes"/>

    <CustomAction Id="Kill_MyApp_instances"
      Directory="TARGETDIR" 
      ExeCommand="taskkill.exe /IM MyApp.exe /F"
      Execute="deferred" 
      Return="ignore" HideTarget="yes" Impersonate="no" />

    <!-- This will create a log in the Temp folder of the user profile by default. NOTE: this is not the full log! The MSI will need to be ran with `/l*v <destination file>` -->
    <CustomAction Id="CopyLog_partial"
      ExeCommand="cmd /c copy &quot;[MsiLogFileLocation]&quot; &quot;%SystemDrive%\Windows\Temp\MyApp-msi.log&quot;" 
      Directory="TARGETDIR" 
      Impersonate="no" 
      Execute="commit" 
      Return="ignore" />
    <CustomAction Id="CopyLog_full"
      ExeCommand="cmd /c copy &quot;[MsiLogFileLocation]&quot; &quot;[LocalAppDataFolder]\Temp\MyApp-msi.log&quot;" 
      Directory="TARGETDIR" 
      Impersonate="no" 
      Execute="immediate" 
      Return="ignore" />
    <InstallExecuteSequence>

      <RemoveExistingProducts Before="InstallValidate" />
      <Custom Action="WixCloseApplications" Before="InstallValidate" /> 
      <Custom Action="Kill_MyApp_instances" After='InstallInitialize'></Custom>
      <Custom Action="LaunchApplication" After='InstallFinalize'>NOT Installed</Custom>

      <Custom Action="CopyLog_partial" After="PublishProduct" /> 
      <Custom Action="CopyLog_full" OnExit="success" />
    </InstallExecuteSequence>

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
      <ComponentGroupRef Id="ELECTRON_FRAGMENTS"/> 
      <ComponentRef Id="Remove_MyApp_Roaming_comp" />
      <ComponentRef Id="Remove_uninstallCache_folder" />
      <ComponentRef Id="Remove_MyApp_programFiles_comp" />
      <ComponentRef Id="Shortcut_startMenu" />
    </Feature>

  </Product>
</Wix>

预期的行为是在MSI的安装过程中删除以前的MSI或更好的所有版本。我知道可以使用CustomAction来完成此操作,但是我想知道是否有更优雅的方法可以做到这一点?

1 个答案:

答案 0 :(得分:0)

  

摘要 :当您在 Add / Remove Programs 中获得两个条目时,主要升级失败。我建议您注释掉所有主要升级   构造并尝试使用最简单的构造心跳   可用-下文说明。


主要升级 :您已使用旧的结构来实施主要升级。有一种更新且简单的方法,如下所示:

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

这有点像“模板”,仅通过使用“正常选项”或简化的选项(如果您愿意)即可以最少的绒毛实现主要升级。使用此模板时,无需添加自己的 RemoveExistingProducts 条目,实际上,在编译时可能会产生“重复的条目/符号”:

  
      
  • 添加上面的 MajorUpgrade element
  •   
  • 注释掉整个 Upgrade element
  •   
  • 注释 RemoveExistingProducts 元素。
  •   

旧结构 MajorUpgrade element 足以实施有效的主要升级,但是您仍然可以使用旧的WiX构造(UpgradeUpgradeVersion元素)以获得对Upgrade table的创作的更细粒度的控制。该表定义了如何处理现有安装。升级表通过匹配升级代码来标识相关产品,然后执行Upgrade table本身为该方案定义的任何操作。

先前的答案 :该主题有多个较旧的答案,请参见以下内容:


更多链接

相关问题