locked
getting the macro of projects' additional directory not via dte RRS feed

  • Question

  • I'm currently working on a console application that will pass a vcxproj file and compile it using GCC. Unfortunately, I don't know how to get the macro value.

    I Know it is ok to get via dte like this :

    System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
       
    object obj = Activator.CreateInstance(t, true);
        DTE dte
    = (DTE)obj;
       
    Solution sln = dte.Solution
        sln
    .Open(args[0]);
       
    foreach (EnvDTE.Project project in sln.Projects)
       
    {
           
    Console.WriteLine("Inspecting project {0}", project.Name);

           
    VCProject vcproj = (VCProject)project.Object;

           
    if (vcproj == null) // this is not a visual c++ project
               
    continue;

           
    IVCCollection cfgs = vcproj.Configurations;
           
    VCConfiguration cfg = cfgs.Item(1);
           
    VCLinkerTool tool = cfg.Tools("VCLinkerTool");
           
    if (tool == null) // this is not a DLL/EXE project
               
    continue;
           
    **cfg.Evaluate("$(solutiondir)")**;
           
    Console.WriteLine("Program database = " + tool.ProgramDatabaseFile);
       
    }

    But, I don't want to use dte because of wasting much time to load vs2008, Just using Microsoft.VisualStudio.VCProjectEngine. Has anyone any idea on this?

    Any info would be much appreciated :)


    Monday, July 2, 2012 8:28 AM

All replies

  • Spinning up all of VS just to process projects seems a bit overboard ;)  Why not just use the MSBuild object model to load the solution/projects and query the values you need from it?

    Ryan

    Monday, July 2, 2012 2:47 PM