WixToolset目录结构复制

WixToolset directory structure copy

我的任务是为 nodejs Web 应用程序创建安装。我找到了压缩整个应用程序的解决方案,使用 Wix 将其复制为一个文件并使用 Wix 自定义操作将其解压缩。这行得通。但它的缺点是目标服务器必须安装压缩软件。在这种情况下 7z.

观察其他安装,他们在没有任何外部软件的情况下提取文件。

我调查了一下 wix,它说我应该使用 HEAT,但我不确定那是什么。有任何简单的开始示例,我可以从概念上理解它。我还发现其他人在 Wix 上的学习曲线很慢。我很认真地学习这个,但我需要一点推动力。我想从这个例子开始。

如何用wix复制整个文件夹?或者最好用什么来练习。也许一些压缩没有第三方软件。

编辑:

这是我的 wixproj 文件的样子:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>3.10</ProductVersion>
    <ProjectGuid>a42f686d-72e6-4452-b066-796c441e0d65</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>SomeManager</OutputName>
    <OutputType>Package</OutputType>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <OutputPath>bin$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj$(Configuration)\</IntermediateOutputPath>
    <DefineConstants>Debug</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <OutputPath>bin$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Product.wxs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="google-credentials-release-server.p12" />
    <Content Include="LICENSE.rtf" />
    <Content Include="some_service.tar.gz">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="XSLT\readme.txt" />
    <Content Include="XSLT\RegisterForCOM.xml" />
    <Content Include="XSLT\XslFile.xslt" />
    <Content Include="XSLT\XslProjectOutput.xslt" />
    <Content Include="XSLT\XslRegisterForCOM.xslt" />
    <Content Include="XSLT\_ERMPanel.xml" />
  </ItemGroup>
  <ItemGroup>
    <WixExtension Include="WixUtilExtension">
      <HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
      <Name>WixUtilExtension</Name>
    </WixExtension>
    <WixExtension Include="WixUIExtension">
      <HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
      <Name>WixUIExtension</Name>
    </WixExtension>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="XSLT\" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ERMPanel\ERMPanel.csproj">
      <Name>ERMPanel</Name>
      <Project>{F62EB2B5-967E-4E32-BE06-89248AFA3385}</Project>
      <Private>True</Private>
      <DoNotHarvest>
      </DoNotHarvest>
      <RefProjectOutputGroups>Binaries</RefProjectOutputGroups>
      <RefTargetDir>INSTALLDIR</RefTargetDir>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(WixTargetsPath)" />
  <Target Name="BeforeBuild">
    <MakeDir Directories="$(IntermediateOutputPath)Harvested XML" />
    <MakeDir Directories="$(IntermediateOutputPath)Harvested Output" />
    <XslTransformation XmlInputPaths="XSLT\RegisterForCOM.xml" XslInputPath="XSLT\XslRegisterForCOM.xslt" OutputPaths="$(IntermediateOutputPath)_COMFiles.txt" Parameters="&lt;Parameter Name='operationType' Value='HeatFiles'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)'/&gt;" Condition="$(MSBuildToolsVersion) &lt;= 12" />
    <XslTransformation XmlInputPaths="XSLT\RegisterForCOM.xml" XslInputPath="XSLT\XslRegisterForCOM.xslt" UseTrustedSettings="true" OutputPaths="$(IntermediateOutputPath)_COMFiles.txt" Parameters="&lt;Parameter Name='operationType' Value='HeatFiles'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)'/&gt;" Condition="$(MSBuildToolsVersion) &gt;= 14" />
    <ReadLinesFromFile File="$(IntermediateOutputPath)_COMFiles.txt">
      <Output TaskParameter="Lines" ItemName="COMFilelist" />
    </ReadLinesFromFile>
    <ConvertToAbsolutePath Paths="@(COMFilelist)">
      <Output TaskParameter="AbsolutePaths" ItemName="ResolvedCOMFilelist" />
    </ConvertToAbsolutePath>
    <Exec Command="&quot;$(Wix)Bin\heat.exe&quot; file &quot;%(ResolvedCOMFilelist.Identity)&quot; -sw -gg -sfrag -nologo -srd -out &quot;$(IntermediateOutputPath)Harvested XML\_%(Filename).com.xml&quot;" IgnoreExitCode="false" WorkingDirectory="$(MSBuildProjectDirectory)" Condition="'%(ResolvedCOMFilelist.Identity)'!=''" />
    <XslTransformation XmlInputPaths="XSLT\RegisterForCOM.xml" XslInputPath="XSLT\XslRegisterForCOM.xslt" OutputPaths="$(IntermediateOutputPath)_COMFiles.txt" Parameters="&lt;Parameter Name='operationType' Value='TransformFiles'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)Harvested XML\'/&gt;" Condition="$(MSBuildToolsVersion) &lt;= 12" />
    <XslTransformation XmlInputPaths="XSLT\RegisterForCOM.xml" XslInputPath="XSLT\XslRegisterForCOM.xslt" UseTrustedSettings="true" OutputPaths="$(IntermediateOutputPath)_COMFiles.txt" Parameters="&lt;Parameter Name='operationType' Value='TransformFiles'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)Harvested XML\'/&gt;" Condition="$(MSBuildToolsVersion) &gt;= 14" />
    <ReadLinesFromFile File="$(IntermediateOutputPath)_COMFiles.txt">
      <Output TaskParameter="Lines" ItemName="XMLFileList" />
    </ReadLinesFromFile>
    <XslTransformation XmlInputPaths="%(XMLFileList.Identity)" XslInputPath="XSLT\XslFile.xslt" OutputPaths="$(IntermediateOutputPath)Harvested Output\%(Filename).wsx" Parameters="&lt;Parameter Name='sourceFilePath' Value='%(XMLFileList.Identity)'/&gt;" Condition="'%(XMLFileList.Identity)'!='' And $(MSBuildToolsVersion) &lt;= 12" />
    <XslTransformation XmlInputPaths="%(XMLFileList.Identity)" XslInputPath="XSLT\XslFile.xslt" UseTrustedSettings="true" OutputPaths="$(IntermediateOutputPath)Harvested Output\%(Filename).wsx" Parameters="&lt;Parameter Name='sourceFilePath' Value='%(XMLFileList.Identity)'/&gt;" Condition="'%(XMLFileList.Identity)'!='' And $(MSBuildToolsVersion) &gt;= 14" />
    <Exec Command="&quot;$(Wix)Bin\heat.exe&quot; project &quot;%(ProjectReference.FullPath)&quot; -projectname &quot;%(ProjectReference.Name)&quot; -pog %(ProjectReference.RefProjectOutputGroups) -gg -sfrag -nologo -out &quot;$(IntermediateOutputPath)Harvested XML\_%(ProjectReference.Name).xml&quot;" IgnoreExitCode="false" WorkingDirectory="$(MSBuildProjectDirectory)" Condition="'%(ProjectReference.FullPath)'!='' And '%(ProjectReference.DoNotHarvest)'!='True' And '%(ProjectReference.ImportedFromVDProj)'=='True'" />
    <HeatProject Project="%(ProjectReference.FullPath)" ProjectName="%(ProjectReference.Name)" OutputFile="$(IntermediateOutputPath)Harvested XML\_%(ProjectReference.Name).xml" ProjectOutputGroups="%(ProjectReference.RefProjectOutputGroups)" ToolPath="$(Wix)Bin\" SuppressAllWarnings="true" AutogenerateGuids="false" GenerateGuidsNow="true" SuppressFragments="true" SuppressUniqueIds="false" Condition="'%(ProjectReference.FullPath)'!='' And '%(ProjectReference.DoNotHarvest)'!='True' And '%(ProjectReference.ImportedFromVDProj)'!='True'" />
    <XslTransformation XmlInputPaths="$(IntermediateOutputPath)Harvested XML\_%(ProjectReference.Name).xml" XslInputPath="XSLT\XslProjectOutput.xslt" OutputPaths="$(IntermediateOutputPath)Harvested Output\_%(ProjectReference.Name).wxs" Parameters="&lt;Parameter Name='projectName' Value='%(ProjectReference.Name)'/&gt;&lt;Parameter Name='projectFilePath' Value='%(ProjectReference.FullPath)'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)Harvested Output\'/&gt;" Condition="'%(ProjectReference.FullPath)'!='' And '%(ProjectReference.DoNotHarvest)'!='True' And Exists('$(IntermediateOutputPath)Harvested XML\_%(ProjectReference.Name).xml') And $(MSBuildToolsVersion) &lt;= 12" />
    <XslTransformation XmlInputPaths="$(IntermediateOutputPath)Harvested XML\_%(ProjectReference.Name).xml" XslInputPath="XSLT\XslProjectOutput.xslt" UseTrustedSettings="true" OutputPaths="$(IntermediateOutputPath)Harvested Output\_%(ProjectReference.Name).wxs" Parameters="&lt;Parameter Name='projectName' Value='%(ProjectReference.Name)'/&gt;&lt;Parameter Name='projectFilePath' Value='%(ProjectReference.FullPath)'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)Harvested Output\'/&gt;" Condition="'%(ProjectReference.FullPath)'!='' And '%(ProjectReference.DoNotHarvest)'!='True' And Exists('$(IntermediateOutputPath)Harvested XML\_%(ProjectReference.Name).xml') And $(MSBuildToolsVersion) &gt;= 14" />
    <XslTransformation XmlInputPaths="XSLT\RegisterForCOM.xml" XslInputPath="XSLT\XslRegisterForCOM.xslt" OutputPaths="$(IntermediateOutputPath)_COMFiles.txt" Parameters="&lt;Parameter Name='operationType' Value='CompileFiles'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)Harvested Output\'/&gt;" Condition="$(MSBuildToolsVersion) &lt;= 12" />
    <XslTransformation XmlInputPaths="XSLT\RegisterForCOM.xml" XslInputPath="XSLT\XslRegisterForCOM.xslt" UseTrustedSettings="true" OutputPaths="$(IntermediateOutputPath)_COMFiles.txt" Parameters="&lt;Parameter Name='operationType' Value='CompileFiles'/&gt;&lt;Parameter Name='intermediateDir' Value='$(IntermediateOutputPath)Harvested Output\'/&gt;" Condition="$(MSBuildToolsVersion) &gt;= 14" />
    <ReadLinesFromFile File="$(IntermediateOutputPath)_COMFiles.txt">
      <Output TaskParameter="Lines" ItemName="WSXFileList" />
    </ReadLinesFromFile>
    <CreateItem Include="$(IntermediateOutputPath)Harvested Output\_%(ProjectReference.Name).wxs" Condition="'%(ProjectReference.FullPath)'!='' And '%(ProjectReference.DoNotHarvest)'!='True' And Exists('$(IntermediateOutputPath)Harvested Output\_%(ProjectReference.Name).wxs')">
      <Output TaskParameter="Include" ItemName="Compile" />
    </CreateItem>
    <CreateItem Include="@(WSXFileList)" Condition="Exists('%(WSXFileList.Identity)')">
      <Output TaskParameter="Include" ItemName="Compile" />
    </CreateItem>
  </Target>
  <!--
    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">
    </Target>
    <Target Name="AfterBuild">
    </Target>
    -->
</Project>

这里是 Product.wsx 文件:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="SomeManager" Language="1033" Version="1.0.0.2" Manufacturer="Certus" UpgradeCode="4810b5e4-21d8-4a45-b289-eafb10dddc0a">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <Media Id="1" Cabinet="Cab1.cab" EmbedCab="yes" />
    <Feature Id="ProductFeature" Title="SomeInstaller" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentGroupRef Id="ERMPanel.Binaries" />
      <ComponentRef Id="comp_5D704CE7_9E55_4FC5_8CB2_6BA4612D6D35" />
      <ComponentRef Id="comp_C9901889_BAD5_4B2C_9407_EAF967B1526C" />
      <ComponentRef Id="comp_03332461_4D6C_4BB5_90D1_4C4D896D7775" />
      <ComponentRef Id="comp_3AE770A3_904C_4458_81BD_300F195A4250" />
      <ComponentRef Id="comp_dir_8F9BAB58_4415_4353_BE9E_36C8F7EEF78A" />
    </Feature>
    <UIRef Id="WixUI_InstallDir" />
    <WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" />
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
    <CustomAction Id="ExtractService" Directory="INSTALLFOLDER" Impersonate="no" Execute="deferred" ExeCommand="7z e -y some_service.tar.gz" Return="check" />
    <CustomAction Id="ExtractService2" Directory="INSTALLFOLDER" Impersonate="no" Execute="deferred" ExeCommand="7z x -y some_service.tar" Return="check" />
    <!--<CustomAction Id="Create_Some_Files" Directory="INSTALLFOLDER" ExeCommand="cmd /C &quot;mkdir some_files&quot;" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />
    <CustomAction Id="Copy_p12" Directory="INSTALLFOLDER" ExeCommand="cmd /C &quot;xcopy google-credentials-release-server.p12 some_files&quot;" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />-->
    <!--<CustomAction Id="Create_Log" Directory="INSTALLFOLDER" ExeCommand="cmd /C &quot;mkdir Logs&quot;" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />-->
    <CustomAction Id="Cleanup_tarfile" Directory="INSTALLFOLDER" ExeCommand="cmd /C &quot;del some_service.tar&quot;" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />
    <CustomAction Id="Cleanup_targzfile" Directory="INSTALLFOLDER" ExeCommand="cmd /C &quot;del some_service.tar.gz&quot;" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />
    <CustomAction Id="Cleanup_bundle" Directory="INSTALLFOLDER" ExeCommand="cmd /C RD &quot;[INSTALLFOLDER]&quot; /s /q" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />
    <!--<CustomAction Id="Cleanup_Some_Files" Directory="INSTALLFOLDER" ExeCommand="cmd /C RD &quot;some_files&quot; /s /q" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />-->
    <InstallExecuteSequence>
      <Custom Action="ExtractService" Before="InstallFinalize">NOT Installed</Custom>
      <Custom Action="ExtractService2" After="ExtractService">NOT Installed</Custom>
      <!--<Custom Action="Create_Some_Files" After="ExtractService">NOT Installed</Custom>
      <Custom Action="Copy_p12" After="Create_Some_Files">NOT Installed</Custom>-->
      <!--<Custom Action="Create_Log" After="ExtractService2">NOT Installed</Custom>-->
      <Custom Action="Cleanup_tarfile" Before="RemoveFiles">REMOVE="ALL"</Custom>
      <Custom Action="Cleanup_targzfile" Before="RemoveFiles">REMOVE="ALL"</Custom>
      <Custom Action="Cleanup_bundle" Before="RemoveFiles">REMOVE="ALL"</Custom>
      <!--<Custom Action="Cleanup_Some_Files" Before="RemoveFiles">REMOVE="ALL"</Custom>-->
    </InstallExecuteSequence>
    <UI />
  </Product>
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="SomeInstaller">
          <Directory Id="ERMPanel.Binaries" />
          <Directory Id="dir_585C16B3_5205_4D63_87F5_D7576697D2A9" Name="some_files">
            <Component Id="comp_3AE770A3_904C_4458_81BD_300F195A4250" Guid="E117F3ED-771F-4547-9713-4A8FCDF173C8" Permanent="no" SharedDllRefCount="no" Transitive="no">
              <File Id="_95238475_7B18_4058_82A2_B56483BCEFD1" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="google-credentials-release-server.p12" Source="google-credentials-release-server.p12" KeyPath="yes" />
            </Component>
          </Directory>
          <Directory Id="dir_8F9BAB58_4415_4353_BE9E_36C8F7EEF78A" Name="Logs">
            <Component Id="comp_dir_8F9BAB58_4415_4353_BE9E_36C8F7EEF78A" Guid="2EB4F74F-2FF4-42A6-B149-746C25950972" KeyPath="yes">
              <CreateFolder Directory="dir_8F9BAB58_4415_4353_BE9E_36C8F7EEF78A" />
              <RemoveFolder Id="id_026B5F17_73B3_4F92_803A_7ED05A3E3D7A" On="uninstall" Directory="dir_8F9BAB58_4415_4353_BE9E_36C8F7EEF78A" />
            </Component>
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="DesktopFolder">
        <Component Id="comp_5D704CE7_9E55_4FC5_8CB2_6BA4612D6D35" Guid="32628FC1-02E6-486C-88BD-1E1B3EB24E44" Permanent="no" SharedDllRefCount="no" Transitive="no">
          <Shortcut Id="_337FA89F_92ED_457C_899C_5344A548FD97" Directory="DesktopFolder" Name="ERMPanel" Show="normal" Target="[INSTALLFOLDER]ERMPanel.exe" WorkingDirectory="INSTALLFOLDER" />
          <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\Installer" Name="comp_5D704CE7_9E55_4FC5_8CB2_6BA4612D6D35" Type="string" Value="User's Desktop directory" KeyPath="yes" />
        </Component>
      </Directory>
      <Directory Id="StartMenuFolder">
        <Component Id="comp_03332461_4D6C_4BB5_90D1_4C4D896D7775" Guid="98E2BC79-8D59-4FEF-B235-92BB611CC608" Permanent="no" SharedDllRefCount="no" Transitive="no">
          <Shortcut Id="_69EBF121_EA14_40B0_A587_1F520C033E45" Directory="StartMenuFolder" Name="ERMPanel" Show="normal" Target="[INSTALLFOLDER]ERMPanel.exe" WorkingDirectory="INSTALLFOLDER" />
          <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\Installer" Name="comp_03332461_4D6C_4BB5_90D1_4C4D896D7775" Type="string" Value="User's Start Menu directory" KeyPath="yes" />
        </Component>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Component Id="comp_C9901889_BAD5_4B2C_9407_EAF967B1526C" Guid="AAA016CC-1B36-417A-A5EA-CB92A1A440AF" Permanent="no" SharedDllRefCount="no" Transitive="no">
          <Shortcut Id="_3732D7A6_3230_4CCB_8037_3DA1D02E98E6" Directory="ProgramMenuFolder" Name="ERMPanel" Show="normal" Target="[INSTALLFOLDER]ERMPanel.exe" WorkingDirectory="INSTALLFOLDER" />
          <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\Installer" Name="comp_C9901889_BAD5_4B2C_9407_EAF967B1526C" Type="string" Value="User's Programs Menu directory" KeyPath="yes" />
        </Component>
      </Directory>
    </Directory>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="packages" Guid="">
        <File Source="some_service.tar.gz" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

我正在做的是手动将节点应用程序压缩到文件 some_service.tar.gz 中,然后将其复制为单个文件,并在自定义操作中将其解压缩。当然那是错误的。我只想将 nodejsdir 放在与 some_service.tar.gz 相同的位置,然后用 heat.exe

复制它

我必须承认我觉得这很混乱,如果你能帮助我,请根据我的例子。

谢谢。

Heat 只是 wix 中包含的收割工具。如果您的构建机器上有您想要在安装机器上复制的目录结构,您可以使用它自动收集数百个文件。

如果您包含的文件更改相当频繁,那么您应该为每个构建设置一个热任务 运行。如果包含的文件相当静态并且您只 add/remove 或不经常移动一些文件,请使用 heat 生成包含所有文件的第一个 WXS,然后在需要时手动更新它。

不要忘记 msi 已经压缩了它包含的所有文件,没有理由将所有文件压缩成一个 zip 然后将其包含到您的 msi 中只是为了在 "installing" 之后解压缩它。您最终会在客户的机器上占用太多不必要的 space 并且可能无法安装,因为 MSI 无法正确计算文件成本并且在解包时可能 运行 磁盘不足 space。

当您使用包含所有文件的 zip 时,您还放弃了 windows 安装程序的所有有用的文件跟踪和处理功能。卸载需要额外的步骤,升级基本上是不可能做好的。失败时无法回滚。

我通过 Wixproj 的 "BeforeBuild" 任务为我们的产品收集了 "help" 目录。

我有一个名为 genComponents.targets 的文件,其中包含

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <Import Project="$(MSBuildThisFileDirectory)..\CommonBuild.props" Condition="$(_CommonBuildPropertyLoaded) != 'true'"/>

    <PropertyGroup>
        <HeatEXE>$(WixToolPath)Heat.exe</HeatEXE>
    </PropertyGroup>

    <Target Name="GenHelpDependsOn">
        <PropertyGroup>
            <HelpHeatArgs>dir &quot;$(MSBuildThisFileDirectory)..\..\Help&quot; -gg -cg BinHelp -dr BINHELP -template fragment -sreg -sfrag -srd -var var.dirHELP -o &quot;$(MSBuildThisFileDirectory)Components\BinHelp.wxs&quot;</HelpHeatArgs>
        </PropertyGroup>
    </Target>  

    <Target Name="GenBinHelp" DependsOnTargets="GenHelpDependsOn">
        <Exec Command="&quot;$(HeatEXE)&quot; $(HelpHeatArgs)" Condition="!Exists('$(MSBuildThisFileDirectory)Components\BinHelp.wxs')"/>
    </Target>    

</Project>

只需使用

 <Target Name="BeforeBuild" DependsOnTargets="GenBinHelp" />

在我的 wixproj 中,它将为包含所有帮助文件的目录的 BinHelp 组件组生成 wxs。我们支持的所有语言都有大约一千个帮助文件。

在 wixproj 中,我将 wxs 添加为 link 并确保它作为 ComponentGroupRef 包含在功能中。

你可以在你的 beforebuild 任务中包含一个 任务和所有正确的参数我只使用第二个文件因为我有很多热任务。关于热有很多不同的论点,你可以用 heat /?去看他们。

只需 运行 heat.exe 到你的 js 目录,看看它是什么样子。


在我用heat收割所有文件的一个项目中有3836个文件。这是构建的过程。我从网络位置获取构建的二进制文件和其他文件的 zip 文件,并将所有文件内容解压缩到一个名为 ZipFolder 的文件夹中。

在我的 wixproj 中,我在之前的构建目标中进行了热调用

<Target Name="BeforeBuild" >
    <Exec Command="&quot;$(WixToolPath)Heat.exe&quot; dir &quot;$(MSBuildThisFileDirectory)..\Binaries\ZipFolder&quot; -ag -cg SDK -dr INSTALLDIR -suid -sreg -sfrag -srd -var var.ZipFolderDir -o &quot;$(MSBuildThisFileDirectory)..\src\InstallerSDK\Components\SDKFiles.wxs&quot;" Condition="!Exists('$(MSBuildThisFileDirectory)..\src\InstallerSDK\Components\SDKFiles.wxs')" />
</Target>

在我的 wixproj 中,我将现有文件 SDKFiles.wxs 添加为 link(添加按钮上的小箭头显示带有 "as link" 的下拉菜单)

我正在使用一些您未在我使用的热调用中定义的 cmd 行开关,以便我可以正确引用生成的文件的组件。首先,我使用 -var var.ZipFolderDir,这会使您的文件源等于 $(var.ZipFolderDir)\rest\of\path.dll。你可以在你的 defineconstants 中定义这个变量(每个配置一个):

   <DefineConstants>Debug;ZipFolderDir=$(MSBuildThisFileDirectory)..\Binaries\ZipFolder\;</DefineConstants>

   <DefineConstants>ZipFolderDir=$(MSBuildThisFileDirectory)..\Binaries\ZipFolder\;</DefineConstants>

另一个区别还在于使用 -dr INSTALLFOLDER,它将顶级目录设置为 INSTALLFOLDER,它由 product.wxs 中的 INSTALLFOLDER 目录定义。

最后是-cg SDK 定义组件组的名称,其中包含所有 heat 收集的文件。这是我们使用 ComponentGroupRef

连接到主 product.wxs 的地方
<Feature Id="ProductFeature" Title="SomeInstaller" Level="1">
  <ComponentGroupRef Id="SDK" />
  <ComponentGroupRef Id="ERMPanel.Binaries" />
  <ComponentRef Id="comp_5D704CE7_9E55_4FC5_8CB2_6BA4612D6D35" />
  <ComponentRef Id="comp_C9901889_BAD5_4B2C_9407_EAF967B1526C" />
  <ComponentRef Id="comp_03332461_4D6C_4BB5_90D1_4C4D896D7775" />
  <ComponentRef Id="comp_3AE770A3_904C_4458_81BD_300F195A4250" />
  <ComponentRef Id="comp_dir_8F9BAB58_4415_4353_BE9E_36C8F7EEF78A" />
</Feature>

并且您可以删除 product.wxs

底部的 ProductComponents 组

我从未使用过 <HarvestProject>,但我知道 wix 已经定义了 Harvest 目标,但我从未花时间弄清楚如何使用它们。我也从未在项目中使用过热量,所以我真的无能为力。由于我们使用的构建过程,我所有的安装程序项目都构建为它们自己的独立项目。通常他们会抓取二进制文件的 zip 并解压缩到二进制文件文件夹,然后在某些文件夹上构建调用 heat 的安装程序。