views:

80

answers:

1

For Visual Studio 6.0, I can connect to a running instance like:

o = GetActiveObject("MSDev.Application")
  • What prog ID do I use for Visual Studio 2003?
  • How do I execute a 'Build Solution' once I have the COM object that references the VS2003 instance?
  • How do I get the string contents of the build output window after executing the build solution command?

Yes, I am aware that I can build a solution from the command line. But in this case, I need to connect to a running instance of Visual Studio.

EDIT: found and submitted an answer, see below.

+2  A: 

After a bit of research (mainly looking at EnvDTE docs), I found the solution to this myself:

To build current solution (code in Python):

def build_active_solution(progid="VisualStudio.DTE.7.1"):
    from win32com.client import GetActiveObject
    dte = GetActiveObject(progid)
    sb = dte.Solution.SolutionBuild
    sb.Build(True)

    output = dte.Windows['Output'].Object.ActivePane.TextDocument.Selection
    output.SelectAll()
    return output.Text
codeape