Include all Files in Bin folder in Wix installer

This solution works with WIX 3.11.

To harvest an entire directory, you can use Heat from the WIX toolset. With Heat we can automatically include all files from a given source directory on every build. To do that we first need to edit the Setup.wixproj:

Define the Harvestpath for Heat:

<PropertyGroup>    
  <DefineConstants>HarvestPath=...\Deploy</DefineConstants>
</PropertyGroup>

Heat will create a .wxs file. So we need to add this file to the compile ItemGroup:

<ItemGroup>
  <Compile Include="Product.wxs" /> <!-- This will be your default one -->
  <Compile Include="HeatGeneratedFileList.wxs" /> <!-- This is the Heat created one -->
</ItemGroup>

Then execute Heat in the BeforeBuild build target:

<Target Name="BeforeBuild">
  <HeatDirectory Directory="..\Deploy" 
    PreprocessorVariable="var.HarvestPath" 
    OutputFile="HeatGeneratedFileList.wxs" 
    ComponentGroupName="HeatGenerated" 
    DirectoryRefId="INSTALLFOLDER" 
    AutogenerateGuids="true" 
    ToolPath="$(WixToolPath)" 
    SuppressFragments="true" 
    SuppressRegistry="true" 
    SuppressRootDirectory="true" />  
</Target>

This will generate the HeatGeneratedFileList.wxs every time the WIX installer is built. The directory ..\Deploy has to be set to the directory of the files to include.
The only thing we have to do to include these files in our installer is to edit the main .wxs file (like Product.wxs in this example). Heat will create a ComponentGroup with the given name from above. This component needs to be referenced in the Feature section of the Product.wxs:

<Feature Id="ProductFeature" Title="DiBA Tool" Level="1">
  <...>
  <ComponentGroupRef Id="HeatGenerated" />
</Feature>

Leave a Comment

techhipbettruvabetnorabahisbahis forumu