How can I programmatically load a solution?

I have see (and used) the rather nice interface for working with Projects.  It is quite easy using Visual Studio 2005 and C# to open a project file (using VCProject from VCProjectEngineObject) and to get the collection of configurations the project contains.  And from the configuration, it is fairly simple to update virtually any setting.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

But what I’m wanting to do starts at a level higher.  I would like to be able to open a solution file and get the list of Projects it contains.  Unfortunately, I’m not finding this documented anywhere (at least not with the other extensibility classes).

 

Is this possible   If not, can you think of any alternatives (short of parsing the solution file myself)



Answer this question

How can I programmatically load a solution?

  • SSIS_rookie

    There is no difference between an Extensibility interface and an Automation interface. DTE is a service, just like anything elsed in the IDE. If you are using a package, just QueryService for SID_SDTE, IID__DTE, which will return a DTE interface. You can then walk through the automation model to load the solution.

    Craig



  • amadas

    Using your reply, I was able to get the keywords I needed to do an intelligent Google search. From there, I found the details I was looking for (including your blog).

    I do appreciate you pointing me in the right direction. Thanks.


  • Min Wang

    You can use the automation model to do this very easily. For example, this macro will load a solution file, then enumerate through the projects loaded in that solution:

    Sub EnumProjects()
    Dim solut As Solution
    Dim proj As Project

    solut = DTE.Solution
    solut.Open("C:\somepath\solution.sln")
    For Each proj In solut.Projects
    MsgBox(proj.Name)
    Next
    End Sub

    Craig



  • Vineet Rao - Microsoft

    I was hoping to do this without having to create this as an add-in. Is there a way of doing this using the Extensibility interface rather than the automation interface

    It seems rather unbalanced (to me) to have a rich extensibility interface for Projects without having support for Solutions.


  • How can I programmatically load a solution?