我可以创建Visual Studio宏以在调试器中启动特定项目吗? [英] Can I create a Visual Studio macro to launch a specific project in the debugger?

查看:92
本文介绍了我可以创建Visual Studio宏以在调试器中启动特定项目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目在同一解决方案文件中同时具有客户端和服务器组件.我通常将调试器设置为在调试时一起启动它们,但通常是在调试器之外启动服务器,以便在仅处理客户端内容时可以根据需要启动和停止客户端. (这要快得多).

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

我试图避免在解决方案资源管理器中打乱启动单个项目的麻烦,而宁愿只是在工具栏上贴一个按钮,该按钮调用一个宏来启动单个项目的调试器(同时保留"F5"类型单独调试以启动两个进程).

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)

(这宽松地基于宏记录器的尝试方式.我不确定导航UI对象模型是否是正确的方法,或者我是否应该研究解决方案/项目对象模型).

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

推荐答案

好.只要加载了解决方案,这似乎就可以在大多数UI(所有?)上下文中起作用:

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

这篇关于我可以创建Visual Studio宏以在调试器中启动特定项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆