title: MSBuild failing to expand environment variables
body: <p>I'm pretty new to MSBuild, so I might be doing something obviously-wrong, but a colleague of mine who's worked with MSBuild a lot can't see any error, so I figured I'd post here and see if anyone else can see it.</p>
  
  <p>I'm converting an old batch file that we used to call <code>ant</code> to MSBuild tasks (because we want to call it from MSBuild) and the environment variables always expand to <code>)</code>for reasons we don't understand.</p>
  
  <p>I have a property group that includes</p>
  
  <pre><code>&lt;PropertyGroup&gt;
    &lt;EnvJavaHome&gt;
      $([System.Environment]::GetEnvironmentVariable("JAVA_HOME"))
    &lt;/EnvJavaHome&gt;
    &lt;!-- ... --&gt;
  &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>(line breaks added for legibility). Now the <a href="http://msdn.microsoft.com/en-us/library/dd633440.aspx" rel="nofollow noreferrer">MSBuild Property Functions reference</a> suggests I'm calling <a href="http://msdn.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx" rel="nofollow noreferrer">System.Environment.GetEnvironmentVariable</a> correctly, but I always get a value of <code>)</code>. The code works perfectly well when I hardcode the value, however.</p>
  
  <p>What obvious thing am I missing?  :o)</p>