Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a Visual Studio macro to launch a specific project in the debugger?

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).

like image 693
Jason Diller Avatar asked Sep 18 '08 19:09

Jason Diller


1 Answers

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
like image 141
Jason Diller Avatar answered Sep 30 '22 01:09

Jason Diller