views:

401

answers:

2

Hi. My project has both client and server components in the same solution file. I usually have the debugger set to start them together when debugging, but it's often the case where I start the server up outside of the debugger so I can start and stop the client as needed when working on client-side only stuff. (this is much faster).

I'm trying to save myself the hassle of poking around in Solution Explorer to start individual projects and would rather just stick a button on the toolbar that calls a macro that starts the debugger for individual projects (while leaving "F5" type debugging alone to start up both processess).

I tried recording, but that didn't really result in anything useful.

So far all I've managed to do is to locate the project item in the solution explorer:

 Dim projItem As UIHierarchyItem

 projItem = DTE.ToolWindows.SolutionExplorer.GetItem("SolutionName\ProjectFolder\ProjectName").Select(vsUISelectionType.vsUISelectionTypeSelect)

(This is based loosely on how the macro recorder tried to do it. I'm not sure if navigating the UI object model is the correct approach, or if I should be looking at going through the Solution/Project object model instead).

+1  A: 

Ok. This appears to work from most UI (all?) contexts provided the solution is loaded:

 Sub DebugTheServer()
    DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
    DTE.ActiveWindow.Object.GetItem("Solution\ServerFolder\ServerProject").Select(vsUISelectionType.vsUISelectionTypeSelect)
    DTE.Windows.Item(Constants.vsWindowKindOutput).Activate()
    DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance")
 End Sub
Jason Diller
A: 

I think the right way is with:

DTE.Solution.SolutionBuild.Debug()

Lou Franco
That will start the default project. I'm after a one-click way to start a non-default project without digging around for it or changing the default.
Jason Diller