title: WiX undefined preprocessor variable
body: <p>I'm starting to use WiX in order to do automated builds to create msi's of my c# projects and am experiencing the error <strong>"Undefined preprocessor variable '$(var.MyProject.TargetDir)'"</strong></p>
  
  <p>I am using the latest WiX v3.0.5419. Inside my wxs file I am trying to use pre-processor variables that are listed on this webpage (<a href="http://blogs.msdn.com/jrock/archive/2008/01/29/complete-list-of-candle-preprocessor-variables.aspx" rel="noreferrer"><strong>http://blogs.msdn.com/jrock/archive/2008/01/29/complete-list-of-candle-preprocessor-variables.aspx</strong></a>)</p>
  
  <pre><code>&lt;Component Id="MyId" Guid="MyGuid"&gt;
     &lt;File Id="MyId" Name="MyName" KeyPath="yes" 
        Source="$(var.MyProject.TargetDir)\MyName.dll" /&gt;
  &lt;/Component&gt;
  </code></pre>
  
  <p>I have added the reference for MyProject to the .wixproj and if I open it up in Notepad I can see the reference.</p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;ProjectReference Include="..\MyProject.csproj"&gt;
      &lt;Name&gt;MyProject&lt;/Name&gt;
      &lt;Project&gt;{guid}&lt;/Project&gt;
      &lt;Private&gt;True&lt;/Private&gt;
    &lt;/ProjectReference&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>This is my nant build script that I use to create the msi. Maybe it's because the .wixproj knows about the project reference which isn't used in the build?</p>
  
  <pre><code>&lt;exec basedir="${tools.wix}" managed="true" program="candle.exe"&gt;
    &lt;arg line='-out "${tools.wix.objfile}"' /&gt;
    &lt;arg value="../MySetup.wxs" /&gt;
  &lt;/exec&gt;
  </code></pre>
  
  <p>Can anyone enlighten me on this please?</p>