title: How to use Wix Toolset's HarvestDirectory?
body: <p>I want to automatically add a folder, <code>C:\example\dir</code>, to a Wix Toolset MSI installer.</p>
  <p>I used the <a href="https://wixtoolset.org/documentation/manual/v3/msbuild/target_reference/harvestdirectory.html" rel="nofollow noreferrer">HarvestDirectory target</a> like this:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;Wix xmlns=&quot;http://schemas.microsoft.com/wix/2006/wi&quot;&gt;
      &lt;?include &quot;Config.wxi&quot; ?&gt;
      &lt;Product Id=&quot;*&quot; Name=&quot;programName&quot; Language=&quot;1033&quot; Version=&quot;1.0.0.0&quot; Manufacturer=&quot;Me&quot; UpgradeCode=&quot;2275bf6b-489e-49f3-a7fd-cfd96ed94d7b&quot;&gt;
          &lt;Package InstallerVersion=&quot;200&quot; Compressed=&quot;yes&quot; InstallScope=&quot;perMachine&quot; Platform=&quot;x64&quot; /&gt;
  
          &lt;MajorUpgrade DowngradeErrorMessage=&quot;A newer version of [ProductName] is already installed.&quot; /&gt;
          &lt;MediaTemplate EmbedCab=&quot;yes&quot; /&gt;
  
          &lt;Feature Id=&quot;ProductFeature&quot; Title=&quot;programName&quot; Level=&quot;1&quot;&gt;
              &lt;ComponentGroupRef Id=&quot;BinDirRefId&quot; /&gt;
          &lt;/Feature&gt;
  
          &lt;UIRef Id=&quot;WixUI_InstallDir&quot; /&gt;
  
          &lt;Property Id=&quot;WIXUI_INSTALLDIR&quot; Value=&quot;INSTALLFOLDER&quot; /&gt;
      &lt;/Product&gt;
  
      &lt;Fragment&gt;
          &lt;Directory Id=&quot;TARGETDIR&quot; Name=&quot;SourceDir&quot;&gt;
              &lt;Directory Id=&quot;ProgramFiles64Folder&quot;&gt;
                  &lt;Directory Id=&quot;INSTALLFOLDER&quot; Name=&quot;programName&quot;&gt;
                      &lt;Directory Id=&quot;BinDirRefId&quot; Name=&quot;bin&quot;&gt;
                      &lt;/Directory&gt;
                  &lt;/Directory&gt;
              &lt;/Directory&gt;
          &lt;/Directory&gt;
      &lt;/Fragment&gt;
  
      &lt;ItemGroup&gt;
          &lt;HarvestDirectory Include=&quot;C:\example\dir&quot;&gt;
              &lt;DirectoryRefId&gt;BinDirRefId&lt;/DirectoryRefId&gt;
          &lt;/HarvestDirectory&gt;
      &lt;/ItemGroup&gt;
  &lt;/Wix&gt;
  </code></pre>
  <p>Visual Studio tells me that <code>ItemGroup</code> isn't a valid child of <code>&lt;Wix&gt;</code>. How should I use this target exactly?</p>