Environment Variables

We have described the basic usage of properties. Now we’ll discuss a few other related aspects. When you are building your applications, sometimes you might need to extract values from environment variables. This is a lot simpler than you might imagine using MSBuild. You can access values, just as you would properties, for environment variables. For example, take a look at the following project file, Properties04.proj.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target Name="PrintEnvVar">
    <Message Text="Temp: $(Temp)" />
    <Message Text="Windir: $(windir)" />
    <Message Text="VS80COMNTOOLS: $(VS80COMNTOOLS)" />
    <Message Text="VS90COMNTOOLS: $(VS90COMNTOOLS)" />
  </Target>

</Project>

In this example, we ...

Get Inside the Microsoft® Build Engine: Using MSBuild and Team Foundation Build now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.