问题描述
我有几个正在运行的进程,我想通过powershell附加到VS调试器.
I have several processes running that I'd like to attach to the VS debugger via powershell.
当前,我可以这样做:Get-Process NServiceBus.Host | Debug-Process
Currently, I can do this: Get-Process NServiceBus.Host | Debug-Process
如果只有一个进程,则会提示我选择正确的调试器,然后我可以继续.
If there is only one process, then I am prompted to select the correct debugger and I can continue.
但是,如果有多个进程,当系统提示我为第二个进程选择调试器时,将无法选择当前正在运行的Visual Studio实例.
However, if there are more than one processes, when I'm prompted to select a debugger for the second process, I am unable to select the currently running instance of Visual Studio.
如何使用Powershell将多个进程附加到Visual Studio的运行实例中进行调试?
How can I use powershell to attach multiple processes to a running instance of visual studio for debuggin?
推荐答案
掌握活动的Visual Studio实例...
To get hold of the active visual studio instance ...
$ dte = [System.Runtime.InteropServices.Marshal] :: GetActiveObject("VisualStudio.DTE")
...并将其附加到一组进程中...
... and to make it attach to a set of processes ...
($ dte.debugger.localprocesses |其中名称-匹配"proc(one | two).exe").Attach()
...如果花费太长时间,则似乎在每次附加连接之间都需要延迟,否则visual studio忙并拒绝了呼叫.
... it seems that a delay might be necessary between each attach if it takes too long otherwise visual studio is busy and rejects the call.
这篇关于通过Powershell将调试器附加到多个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!