We've been doing some bug fixing this week and have ended up creating a new plug-in, so to ease the debugging pain, I have used some post build actions to deploy the plug-in while debugging, see this post for more details. The one thing that I hadn't automated was attaching to the debugger, which while not very time consuming it was starting to grate me a little bit, particularly after I mistyped a property name twice in a row.
So after a bit of googling I found this and this, which I have combined into this post. Note that I've used VS 2008, but this should work in VS 2010, just need to add import EnvDTE100 to the macro, I haven't tried it though.
In Visual Studio go to:
- Tools | Macros | Macro Explorer
- Right Click MyMacros | New Module
- Name it AttachDebugger
- Double Click on Attach Debugger to open the Editor.
- Paste the code below:
- Save it.
- To add the Shortcut, now go to Tools | Options | Environment | Keyboard
- Type W3WP and enter your shortcut
- Click Assign and off you go.
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module AttachDebugger
Sub W3WP()
Try
DTE.Debugger.DetachAll()
For Each proc As EnvDTE.Process In DTE.Debugger.LocalProcesses
If proc.Name.IndexOf("w3wp.exe") <> -1 Then
proc.Attach()
End If
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
If you are deploying asynchronous plugins as well, you could create another Sub that attaches to the asynchronous service and simply give it another shortcut.
No comments:
Post a Comment