title: WiX - How to link an ExePackage element into a Product
body: <p>I am trying to include the VC++ Redistributable 2013 prerequisites installation in my MSI installer.</p>
  
  <p>I have modified the <code>Fragment</code> written by <a href="http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Install-the-Visual-C-redistributables-file-vcredist-x86-exe-td7580169.html" rel="nofollow noreferrer">this guy</a> to quietly download and install the vcredist_x86.exe package after performing a registry check (file - MyWixProject/vcredist.wixobj):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"&gt;
      &lt;?define vcredist_x86="http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe"?&gt;
  
      &lt;Fragment&gt;
          &lt;util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\DevDiv\vc\Servicing\12.0\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum" Value="Install" Variable="vcredist" /&gt;
          &lt;PackageGroup Id="vcredist"&gt;
              &lt;PackageGroupRef Id="InstallVCRedist"/&gt;
              &lt;ExePackage Id="vcredist_x86"
                          Cache="no"
                          Compressed="no"
                          PerMachine="yes"
                          Permanent="yes"
                          Vital="yes"
                          Name="Redist\vcredist_x86.exe"
                          SourceFile="Redist\vcredist_x86.exe"
                          DownloadUrl="$(var.vcredist_x86)"
                          InstallCommand="/q"
                          DetectCondition="vcredist AND (vcredist &amp;gt;= 1)"&gt;
                  &lt;ExitCode Value ="3010" Behavior="forceReboot" /&gt;
              &lt;/ExePackage&gt;
          &lt;/PackageGroup&gt;
      &lt;/Fragment&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <p>I am trying to reference this <code>Fragment</code> from my <code>Product</code> element (file MyWixProject/Product.wxs). I read that "<a href="http://wixtoolset.org/documentation/manual/v3/xsd/wix/fragment.html" rel="nofollow noreferrer">The contents of a Fragment element can be linked into a product by utilizing one of the many *Ref elements</a>". But how can a <code>ExePackage</code> or its <code>PackageGroupRef</code> be referenced from the main <code>Product</code> element? Or is there another way to compile the <code>.wixobj</code> and its <code>Fragment</code> from within the <code>.wxs</code> <code>Product</code>?></p>