You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WiX Bundle主升级未复制MSI包新文件问题求助

Wix Bundle升级文件缺失问题排查

问题现象

  • 已安装旧版本(v3.01.x.y)的情况下,安装包含多子包的新版本(v3.31.x.y)Bundle时无报错,控制面板和PackageCache均显示新版本,但主包StudioInstallerMSI的目标目录完全缺失,新文件未复制到目标路径
  • 次要包FLMInstallerMSI存在相同问题:控制面板显示升级到最新版本,但旧版本文件未被新版本替换
  • 卸载旧版本后再安装新版本,所有文件可正常部署;仅升级流程出现异常
  • 单独安装主MSI包StudioInstallerMSI时,会先卸载旧版本、创建目标目录并复制新文件,但随后该目录被瞬间删除

相关代码片段

Bundle配置(bundle.wxs)

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">

  <?include $(var.SolutionDir)\StudioInstaller\StudioInstaller\Variables.wxi?>

  <Bundle Name="$(var.SciFullProductName)"
          Version="!(bind.packageVersion.StudioInstallerMSI)"
          Manufacturer="!(bind.packageManufacturer.StudioInstallerMSI)"
          UpgradeCode="$(var.UpgradeCode)"
          IconSourceFile="$(var.ProjectDir)\..\StudioInstaller\Resources\STUDIO.ICO">

    <WixVariable Id="PrerequisitesDirectory" Value="Prerequisites\" />

    <Variable Name="BA_SciProductName" Value="$(var.SciProductName)" />

    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
      <bal:WixStandardBootstrapperApplication LicenseFile=".\Resources\EULA.rtf"
                                              LogoFile=".\Resources\Banner.jpg"
                                              ThemeFile="$(var.SolutionDir)\SciWixLibrary\SciBaseTheme.xml"
                                              LocalizationFile="$(var.SolutionDir)\SciWixLibrary\SciBaseTheme.wxl" />
    </BootstrapperApplicationRef>

    <Chain>
      <PackageGroupRef Id="NetFx48Redist" />
      <PackageGroupRef Id="VCRedist_x64" />
      <PackageGroupRef Id="SqlLocalDB_x64" />
      <PackageGroupRef Id="FLMInstallerMSI" />
      <MsiPackage Id="StudioInstallerMSI" SourceFile="$(var.StudioInstaller.TargetPath)" Vital="yes" Compressed="yes">
        <MsiProperty Name="BUNDLE_UI_LEVEL" Value="[WixBundleUILevel]" />
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix>

主MSI配置(StudioInstallerMSI主wxs)

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <?include $(sys.CURRENTDIR)\Variables.wxi?>
  <?include $(sys.CURRENTDIR)\..\..\SciWixLibrary\SharedVariables.wxi?>
  
  <Product Id="*" Name="$(var.SciProductName)" Language="1033" Codepage='1252' Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">

    <Package Id='*' Keywords='Installer' Description="$(var.SciProductName) v. $(var.ProductVersion) Installer"
             Comments='$(var.SciProductName) is a registered trademark of $(var.Manufacturer)' Manufacturer='$(var.Manufacturer)'
             InstallerVersion='500' Languages='1033' Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade AllowSameVersionUpgrades="yes" AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." Disallow="no" Schedule="afterInstallInitialize" />

    <MediaTemplate EmbedCab="yes" />

    <!-- The upgrade code of the old legacy product used in the InstallShield based installers -->
    <Upgrade Id="9BEACA3B-D4F4-45E6-A288-509C608CF1A6">
      <UpgradeVersion OnlyDetect='no' Property='OLD_IS_PRODUCTCODE' Maximum='3.0.0.0' IncludeMaximum='no' IgnoreRemoveFailure='no' />
    </Upgrade>

     <Feature Id="StudioComponents" Title="Sciemetric Studio Components" Level="1">
      <ComponentGroupRef Id="HarvestedSTComponents" />
      <ComponentRef Id="cmpRemoveSTUnversionedFiles" />
    </Feature>
   </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="SystemFolder" />
      <Directory Id="ProgramFiles64Folder">
        <Directory Id="SciemetricDIR" Name="Sciemetric">
          <Directory Id="SciStudioDIR" Name="Sciemetric Studio" />
        </Directory>
      </Directory>
    </Directory>
  </Fragment>
</Wix>

排查方向

  1. 调整MajorUpgrade调度时机
    主MSI中MajorUpgrade的Schedule当前设为afterInstallInitialize,该时机可能导致新版本文件复制后,旧版本的卸载流程触发目录删除。建议修改为afterInstallValidate,让旧版本卸载在新版本文件复制前完成。
  2. 检查旧版本卸载自定义逻辑
    旧版本(InstallShield打包的v3.01.x.y)可能存在自定义卸载动作(如删除安装目录的脚本),新版本升级时该动作可能在文件复制后执行,导致目录被删除。需验证旧版本卸载流程的具体行为。
  3. 验证组件与文件收割配置
    确认HarvestedSTComponents组件组是否正确包含所有需部署的文件,且组件Guid符合Wix规则(文件变动时是否自动更新Guid,或启用autoGenerateGuids="yes")。若Guid未正确更新,MSI会判定文件无需替换。
  4. 确认Bundle升级检测逻辑
    确保新旧版本的UpgradeCode一致,Bundle需基于此识别旧版本并执行升级流程,而非全新安装。
  5. 排查自定义清理组件
    主MSI中的cmpRemoveSTUnversionedFiles组件若包含清理逻辑,需确认其执行时机是否合理,避免误删新版本刚复制的文件。
  6. 分析安装日志
    生成详细MSI日志(安装时添加参数/l*v install.log),查看文件复制、目录操作的具体步骤,定位触发目录删除的动作。

内容的提问来源于stack exchange,提问作者Tiger Galo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 06:56:05