visual-studio-2010visual-studiovisual-studio-2012

How to define environment variables in a VS solution and use them in csproj files?


I would like to define user environment variables in a Visual Studio solution. Then I would like to use them in the project files. For example:

<ProjectReference Include="$(MyUserVar)\MyProject.csproj">

Is it possible?


Solution

  • This can be done in the VS property sheet.

    1. Go to the Property Manager tab if it's not highlighted yet.

    2. Double click on the newly created property sheet.

    3. Go to the User Macros node and press the Add Macro button. Insert name to the value field as you'd like and set this macro as an environment variable in the build environment.

    enter image description here

    Detailed step-by-step instructions can be referred here: https://sites.google.com/site/pinyotae/Home/visual-studio-visual-c/create-user-defined-environment-variables-macros (archived)