WixToolset目录结构副本

时间:2016-05-16 08:00:12

标签: node.js wix windows-installer

我有一项任务是为nodejs Web应用程序创建安装。我发现压缩整个应用程序的解决方案将其作为一个文件复制到Wix并使用wix自定义操作提取它。这有效。但它的缺点是targt服务器必须安装压缩软件。在这种情况下7z。

观看其他安装,他们正在使用任何外部软件提取文件。

我已经调查了一下wix,它说我应该使用HEAT,nut我不知道是什么。有任何简单的启动示例,我可以在概念上理解它。我也发现其他人在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复制它

我必须承认,如果你能根据我的例子帮助我,我觉得这很令人困惑。

谢谢。

1 个答案:

答案 0 :(得分:2)

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

如果您所包含的文件发生频繁更改,则应该设置一个加热任务来运行每个构建。如果包含的文件是静态的,并且您只是偶尔添加/删除或移动某些文件,请使用heat生成包含所有文件的第一个WXS,然后在需要时手动更新。

不要忘记msi已经压缩了它包含的所有文件,没有理由将所有文件压缩成zip,然后将其包含在你的msi中,只有在&#34;之后解压缩它。安装&#34;它。您最终会在客户的计算机上不必要地占用太多空间,并且可能无法安装,因为MSI无法正确执行文件成本核算,并且在解压缩时可能会耗尽磁盘空间。

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

我收获了#34;帮助&#34;我们的产品目录为&#34; BeforeBuild&#34;我wixproj的任务。

我有一个名为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添加为链接,并确保它作为ComponentGroupRef包含在一个功能中。

您可以只包含&lt; Exec&gt;在您的beforebuild任务中的任务与所有正确的参数我只使用第二个文件,因为我有很多热任务。加热有很多不同的论据,你可以用热量来看看它们吗?去看他们。

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


在我收获所有加热文件的项目中,有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作为链接(添加按钮上的小箭头显示下拉为&#34;作为链接&#34;)

我使用了一些您在热呼叫中未定义的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定义了组件组的名称,该名称包含所有通过加热收集的文件。这是我们使用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并解压缩到Binaries文件夹,然后在一些文件夹上构建调用heat的安装程序。