title: Wix Toolset - Variable Shared Across Projects/Solution
body: <p>I am trying to share a variable across 2 of my wix projects but I am having issues.</p>
  
  <p>Basically I am trying to accomplish having the version number of my bootstrapper and MSI in one file and then this referenced by the two projects.</p>
  
  <p>I have three projects</p>
  
  <ul>
  <li>Install - This is a setup project that creates an .msi file</li>
  <li>Bootstrapper - This is a Wix Bootstrapper project that references and runs the .msi file at runtime</li>
  <li>Shared - This is a wixlib project that contains a single variable in a fragment that is the version number</li>
  </ul>
  
  <p>The shared project contains a single file i have called GlobalVars.wxs and looks like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
      &lt;Fragment&gt;
      &lt;?define VersionNo = "6.86.123"?&gt;
      &lt;/Fragment&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <p>The bootstrapper references this variable like this</p>
  
  <pre><code>&lt;Bundle Name="ProgramName" Version="$(var.VersionNo)" Manufacturer="CompanyName" UpgradeCode="Guid" Compressed="no"&gt;
  </code></pre>
  
  <p>and the Install project references the variable like this - and has a reference to the .wxs from the shared project</p>
  
  <pre><code>  &lt;Product Id="*" Name="Program Name" Language="2057" Version="$(var.VersionNo)" Manufacturer="CompanyName" UpgradeCode="guid"&gt;
      &lt;Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"  InstallPrivileges="elevated"/&gt;
      &lt;?include GlobalVars.wxs ?&gt;
  </code></pre>
  
  <p>Both projects have references setup to the wixlib project that contains the variable </p>
  
  <p>When i attempt to build I am getting this error on both the install and bootstrapper project </p>
  
  <pre><code>Undefined preprocessor variable '$(var.VersionNo)'.
  </code></pre>
  
  <p>If the <code>&lt;?include?&gt;</code> tag resolved the issue I would expect the install project to build</p>
  
  <p>Does anyone have any ideas as to what I might be doing wrong here? </p>
  
  <p>To me it looks like the variable has not been defined by the time the build attempts to call it, but I am unsure as to show to change the order to ensure the variable is defined before anything else</p>
  
  <p>Thanks for the help </p>