WiX v5 is here! Let us help.

Exclude Files from Advanced Harvesting

Often it is easier to harvest all the files in a directory or project and exclude the few that are not desired. This is easy with the <Exclude/> element. The Files attribute uses a syntax like MSBuild to include all directories, **, and wildcards.

For example, to include a directory tree of files without any .pdb files use the following:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:fg="http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd">
  <Fragment>
    <ComponentGroup Id="HarvestedComponents">
      <Component Directory="InstallFolder">
        <fg:HarvestFolder Source="path\to\harvest\**">
          <fg:Exclude Files="**\*.pdb" />
        </fg:HarvestFolder>
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

Use multiple <Exclude/> elements to prevent different sets of files from being included. For example,

<Component Directory="SourceFolder">
  <fg:HarvestProject Name="ExampleProject"
      OutputGroup="SourceFilesProjectOutputGroup">
    <fg:Exclude Files="README.txt" />
    <fg:Exclude Files="**\*.ignore" />
  </<fg:HarvestProject>
</Component>

Sometimes it is necessary to specialize a single file from a harvested folder. Rather than use the <Exclude/> element to prevent the file from being harvested and then add an explicit <File/> element to include the file in the installation package, consider using the HarvestFile element instead.