链接 wixlib 时处理孤立组件

Dealing with orphaned components while linking wixlib

我的任务是基于第 3 方提供的同一个 wixlib 构建 2 个安装程序。完整安装程序包括所有组件,精简版仅包含核心内容。我假设 wixlib 具有以下结构:

<Fragment>
  <ComponentGroup Id="CoreStuff">
    <!-- List of components for this bit, roughly 5MB -->
  </ComponentGroup>
</Fragment>
<Fragment>
  <ComponentGroup Id="ExtraStuff">
    <!-- List of components for this bit, roughly 45MB -->
    <ComponentRef Id="BigFile1"/>
  </ComponentGroup>
  <Component Id="BigFile1">
    <File Id="BigFile1_bin" Name="BigFile1.bin"/>
  </Component>
</Fragment>

安装程序是在 msbuild 中构建的。这些组件通过以下方式包含在项目中:

<Feature Id="ThirdPartyStuff">
  <ComponentGroupRef Id="CoreStuff"/>
  <?if $(var.Configuration) = "Full"?>
  <ComponentGroupRef Id="ExtraStuff"/>
  <?endif?>
</Feature>

最后,正如预期的那样,我得到了 LGHT0267 错误:

error LGHT0267: Found orphaned Component 'BigFile1'. If this is a Product, every Component must have at least one parent Feature. To include a Component in a Module, you must include it directly as a Component element of the Module element or indirectly via ComponentRef, ComponentGroup, or ComponentGroupRef elements.

有没有人想出如何有选择地使用 wixlib 中提供的组件的解决方法?我可以将 ExtraStuff 作为用户的单独功能包括在内,但这里的目标是缩小安装程序。我可以礼貌地要求 ThirdParty 提供两个单独的 wixlib,但我想避免它。

我不认为 wix 有能力只使用 wixlib 包的一部分。将 wixlibs 视为合并模块(没有可查看的表)。你不能只消耗一半的合并模块,你也不能只消耗一半的wixlib。

恐怕你得请第三方将他们的 wixlib 分成两个包。

经过一番努力,我找到了解决方法,讨厌的解决方法:

  1. 像往常一样创建虚拟 wixproject 并包含 wixlib。
  2. 添加虚拟项目作为最终项目的依赖项
  3. 在虚拟项目的 post-build 事件中将 powershell 脚本设置为 运行,这将:
    • 使用 dark.exe
    • 使用二进制输出(开关 -x)反编译 dummy.msi
    • 根据 dummy.wxs 制作 new.wxs 文件,包含使组件成为条件的标签
  4. 在最终项目中包含 new.wxs