title: In Wix, can one define a ComponentGroup and Directory at the same time?
body: <p>I'm new to WiX.  Very new.  Is there a way to define both a ComponentGroup and a Directory at the same time?</p>
  
  <p>I have a large number of files, on the order of 300 or so total, that need to be split into a number of groups, with each group having somewhere around 50 files.  </p>
  
  <p>Using heat.exe, I was able to create a Fragment that creates Components for each file.  I would like to avoid having to re-list each and every one of these components in a separate ComponentGroup definition.  I would love to be able to wrap the list of components generated by heat in a ComponentGroup definition, then simply use that ComponentGroupRef inside of a DirectoryRef structure.</p>
  
  <p>I hope this clears it up.  I currently must do:</p>
  
  <pre><code>&lt;DirectoryRef Id="FilesDir"&gt;
    &lt;Component Id="a.txt" Guid="YOUR-GUID"&gt;
      &lt;File Id="a.txt" KeyPath="yes" Source="SourceDir\a.txt" /&gt;
    &lt;/Component&gt;
    &lt;Component Id="b.txt" Guid="YOUR-GUID"&gt;
      &lt;File Id="b.txt" KeyPath="yes" Source="SourceDir\b.txt" /&gt;
    &lt;/Component&gt;
  ...
    &lt;Component Id="z.txt" Guid="YOUR-GUID"&gt;
      &lt;File Id="z.txt" KeyPath="yes" Source="SourceDir\z.txt" /&gt;
    &lt;/Component&gt;
  &lt;/DirectoryRef&gt;
  
  &lt;ComponentGroup Id="FilesGroup"&gt;
    &lt;ComponentRef Id="a.txt"&gt;
    &lt;ComponentRef Id="b.txt"&gt;
  ...
    &lt;ComponentRef Id="z.txt"&gt;
  &lt;/ComponentGroup&gt;
  </code></pre>
  
  <p>I have to list every file twice.  That stinks.  </p>
  
  <p>I'd like to be able to do:</p>
  
  <pre><code>&lt;ComponentGroup Id="FilesGroup"&gt;
    &lt;Component Id="a.txt" Guid="YOUR-GUID"&gt;
      &lt;File Id="a.txt" KeyPath="yes" Source="SourceDir\a.txt" /&gt;
    &lt;/Component&gt;
    &lt;Component Id="b.txt" Guid="YOUR-GUID"&gt;
      &lt;File Id="b.txt" KeyPath="yes" Source="SourceDir\b.txt" /&gt;
    &lt;/Component&gt;
  ...
    &lt;Component Id="z.txt" Guid="YOUR-GUID"&gt;
      &lt;File Id="z.txt" KeyPath="yes" Source="SourceDir\z.txt" /&gt;
    &lt;/Component&gt;
  &lt;/ComponentGroup&gt;
  
  &lt;DirectoryRef Id="FilesDir"&gt;
    &lt;ComponentGroupRef Id="FilesGroup"&gt;
  &lt;/DirectoryRef&gt;
  </code></pre>
  
  <p>Is that possible?  Is there some other way of making this easier that I'm just not seeing?</p>
  
  <p>Update: We abandoned Wix, and therefore I'm not sure if I should mark a solution or not.  If someone feels one of the answers below IS the answer to my now-rather-old question, please let me know, and I'll mark the appropriate answer as such.</p>