WiX 组件组条件

WiX ComponentGroup Condition

我有一个 Feature,它引用了一个 ComponentGroupComponentGroup 在另一个文件的 Fragment 中定义,包含 Component 的数量。

此项目在产品的多个版本之间共享,我想维护一个版本的 Product.wxs 文件(代码库在产品版本之间是通用的)。

我可以在 ComponentGroup 上设置条件以确定是否将其包含在安装程序中吗?

是的,你可以。下面的代码片段是完全有效的 WiX 代码:

<Feature Id="MyFeature" Title="Some title" Level="100">
  <ComponentGroupRef Id="ComponentGroup1"/>
  <ComponentGroupRef Id="ComponentGroup2"/>
  <?if $(var.IncludeAnotherGroup) = true ?>
    <ComponentGroupRef Id="AnotherGroup"/>
  <?endif ?>
</Feature>

您可以在构建时提供 IncludeAnotherGroup 变量的值,例如像这样(NAnt 代码):

<candle ...>
  <defines>
    <define name="IncludeAnotherGroup" value="true" />
  </defines>
  <sources basedir="${paths.wxs}">
    <include name="**.wxs"/>
  </sources>
</candle>