如何在 WiX 中为 ComponentGroupRef 指定文件位置

How to specify file location for ComponentGroupRef in WiX

我是 WiX 新手。我已经使用 Heat 工具基于文件夹生成了一个 wxs 文件。现在如何在 product.wxs 中使用 wxs 文件而不实际将生成的文件包含到解决方案中。仅供参考,我知道我可以使用 "ComponentGroupRef Id" 引用生成的文件,但是如何指定 ComponentGroupRef 的文件路径?

您不必指定该组件组所在文件的路径。你基本上应该做两件事:

  • 确保您的热生成文件包含在编译过程中。您可以直接将它放在其他 wxs 文件旁边,然后让 candle 选择该文件夹
  • 正如您提到的,在 ComponentGroupRef 元素
  • 的帮助下从您的 product.wxs 引用该组件组

检查构建目标之前的收获元素。

<Target Name="BeforeBuild">
  <HarvestDirectory Include="$(SourceDir)">
    <DirectoryRefId>INSTALLDIR</DirectoryRefId>
    <ComponentGroupName>cmpMain</ComponentGroupName>
    <PreprocessorVariable>var.SourceDir</PreprocessorVariable>
    <SuppressUniqueIds>false</SuppressUniqueIds>
    <SuppressCom>true</SuppressCom>
    <SuppressRegistry>true</SuppressRegistry>
    <SuppressRootDirectory>true</SuppressRootDirectory>
    <KeepEmptyDirectories>false</KeepEmptyDirectories>
  <Transforms>DefaultTransform.xsl</Transforms>
</HarvestDirectory>

创建组件组并引用生成的文件:

<ComponentGroup Id="ProductComponents" Directory="INSTALLDIR">
  <ComponentGroupRef Id="cmpMain" />
</ComponentGroup>

*您可以跳过此步骤并直接转到功能 table 中的引用,但我更喜欢在不同的 Components.wxs 文件中定义所有组件。

然后在特征中包含组件组table:

<Feature Id="Main" Title="Main" Level="1" ConfigurableDirectory="INSTALLDIR" >
  <ComponentGroupRef Id="ProductComponents" />
</Feature>