Dabiel Kabuto
Dabiel Kabuto

Reputation: 2862

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?

Upvotes: 4

Views: 2833

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50687

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)

Upvotes: 1

Related Questions