Getting Visual Studio macros in console app

Posted by Paul Steckler on Stack Overflow See other posts from Stack Overflow or by Paul Steckler
Published on 2010-03-25T07:56:46Z Indexed on 2010/03/25 8:03 UTC
Read the original article Hit count: 455

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?

© Stack Overflow or respective owner

Related posts about visual-studio

Related posts about macros