Environment Setter

September 2006

What it Does

This is a simple add-in for Visual Studio 2005 that can be used to set environment variables in the DevEnv.exe process.  The add-in does the following:

You should already be aware that Visual Studio C/C++/NMake projects can further modify the spawned processes environments, and that those changes may conflict with yours. 

How to Install It

There's no setup program for the add-in, because one of the things that I wrote the add-in for was to add the WiX tools to the environment so that I could build setups.

To set up the add-in simply:

  1. Copy the files to %ProgramFiles%\Microsoft Environment Setter Add-in\
  2. In Visual Studio go to Tools -> Options -> Add-in/Macro Security
  3. In the list box for Add-in File Paths add %ProgramFiles%\Microsoft Environment Setter Add-in\
  4. Close and re-open Visual Studio.
  5. Go to Tools -> Add-in Manager... and check the the add-in is visible.
  6. Copy the file Environments-v1.1.xsd to %ProgramFiles%\Microsoft Visual Studio 8\Xml\Schemas\ in order to get automatic Intellisense when you open and edit a .environ file.

Environment File Format

A typical environment file might look like this:

Example.environ 

This sample is included in the disribution. 

The <Environment> tag is the element that defines an environment for your solution.  This needs to have a Name attribute that matches the solution file name exactly.  The <Set> elements should be self explanitory.  You can define <Property> elements before any of the <Environment> elements, and substitute them in the appropriate Value attribute using $(PropertyName) in the attribute text.  This is similar the way properties work in, say, MSBuild.

Any existing environment variables can also be substituted by using $(env.PATH).   Note that everything is case sensitive.  Be careful of that.  Do a SET on the command line to see what the correct case is.

Copyright © Microsoft Corporation. All rights reserved.