user68416
user68416

Reputation: 287

How to add environmental variable to VS solution (.sln )

I need to have my own environmental variable (like $(VsInstallDir) ) for all projects in solution. How can i define it in my solution ?

I'm using VS2008, C++ solution

Upvotes: 14

Views: 14899

Answers (2)

Dani van der Meer
Dani van der Meer

Reputation: 6207

I had a similar problem and consequent question. Take a look at the answers there. The short answer is: use property sheets.

For example:

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
    ProjectType="Visual C++"
    Version="8.00"
    Name="MyIncludes"
    >
    <UserMacro
        Name="BoostInclude"
        Value="C:\Program Files\boost\boost_1_35_0"
        PerformEnvironmentSet="true"
    />
</VisualStudioPropertySheet>

Upvotes: 10

Chris Lawlor
Chris Lawlor

Reputation: 48972

You could create a project (dll) which simply held all of your environment varaibles; call it solution_env.dll or something. All of the other projects in the solution would have to reference that dll.

I suspect that there are other, better ways to accomplish what you are trying to do, but then that depends on what you are actually trying to do. What I mean is, you have some goal, and you've already decided that the solution to your goal is to have a solution-wide environment variable(s), so you've asked how to do that. It may be more beneficial to ask if there are other ways to accomplish what you are really trying to do.

Upvotes: 0

Related Questions