getting the value of $(ProjectDir), $(SolutionDir) in a vcproj file

3ggerhappy picture 3ggerhappy · Feb 2, 2011 · Viewed 19.7k times · Source

Is it possible to get the value of $(ProjectDir) or $(SolutionDir) programatically outside Visual Studio? My scenario is I need to read a vcproj file as a text file and get its properties like the outputdirectory etc.. problem is some properties contain environment variables like $(SolutionDir) and the like.

Answer

Hans Passant picture Hans Passant · Feb 2, 2011

Well, you found out that looking at the .vcproj file isn't enough. You need to know the .sln file as well. You're kinda stuck until you resolve this. Visual Studio will always create a .sln file when it loads a .vcproj file and cannot find a matching .sln. Maybe you want to do that too.