WiX .wixproj 文件中的 PreBuildEvent 与 HeatDirectory

PreBuildEvent vs HeatDirectory in a WiX .wixproj file

PreBuildEventHeatDirectory有什么关系 .wixproj 文件?

要调用 heat.exe 我已经配置了预构建事件:

  <PropertyGroup>
    <PreBuildEvent>"$(WIX)bin\heat.exe" dir "$(SolutionDir)\Source" ^
                       -var var.SourceDir ^
                       -dr INSTALLFOLDER ^
                       -cg MyComponents ^
                       -ag -ke -scom -sfrag -srd -sreg -suid -svb6 ^
                       -o "$(ProjectDir)MyComponents.wxs"</PreBuildEvent>
  </PropertyGroup>

但是还有 HeatDirectory 元素:

<!-- To modify your build process, add your task inside one of the
     targets below and uncomment it. Other similar extension points
     exist, see Wix.targets.
<Target Name="BeforeBuild">
  <HeatDirectory ... >
  </HeatDirectory>
</Target>
<Target Name="AfterBuild">
</Target>
-->

有什么关系,我应该使用哪一个?

两者相同。

Prebuild 事件直接调用加热过程以自动生成 MyComponents.wxs 文件。

使用 "HeatDirectory" 或 "HarvestDirectory" 时,之前的构建目标执行相同的操作。

主要区别在于此选项中哪个更适合您。 命令行,如上所述,或xml风格,如:

  <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>