Getting Visual Studio macros in console app
- by Paul Steckler
In a Visual Studio extension, you can get the default include paths for all projects with C# code like:
String dirs = dte2.get_Properties("Projects", "VCDirectories");
where dte2 is the Visual Studio application object. Usually, those directories contain
macros like $(INCLUDE). You can expand those macros by looking at dte2.Solution.Projects, finding the relevant project in that collection; from the project, look at project.Configurations, find the relevant configuration, and call its Evaluate method.
In VS2005/VS2008, there's a .vssettings file that contains the VCDirectories. In VS2010, there's a property sheet with the same information. A console application can just parse those files -- great. But how can you expand the macros?
As a first step, I tried instantiating a VCProjectEngine object in a console app, but that just resulted in a COM failure. So I don't know how to instantiate a VCProject object in
order to follow the same strategy I used in a VS extension.
Where are the macro bindings stored?