Search code examples
visual-studio-2010visual-studioenvironment-variablesprojects-and-solutions

Defining Project Paths in a Solution via Macro/Environment Variable


Is there a way to define the project file path in a solution using a user macro/environment variable? I can't seem to do that.

Kind of like an environment variable is used to define the additional include directories in a C++ project, except I want to do the same for the location of a project file in a solution.

I've tried editing the solution in a text editor to change the path to start with %MyMacroName% or $(MyMacroName) but neither of them seems to parse just right. The project files can't be located when the solution is opened.


Solution

  • In .sln file use syntax "%ENV_VAR%rest_of_the_path\test.csproj"

    In .csproj file use syntax "$(ENV_VAR)rest_of_the_path\test.dll"

    That works for me, ENV_VAR is custom environment variable defined for operating system like ENV_VAR = "C:\MyPath\"