Faster Visual Studio Attach to Process Debugging
Visual Studio's Attach to process is an alternative to the good ol' F5 which builds your solution and lets you debug it. However Attach to process can be made a little bit easier using a few helpful tricks.
First of all, we need to add an external tool to Visual Studio:
- Go to Tools->External Tools and press Add to create a new tool.
- Fill in these values in the correct field:
Title: list w3wp
Arguments: list wp
Make sure "Use Output window" is checked and remember what order your tool has in the list, for instance 4th. Press Ok.
Remember that your w3wp processes will be in Visual Studio's output window when using this tool!
Now we want easy access to our tool. Let's give it a shortcut command:
- Go to Tools->Options->Environment->Keyboard.
- In the Show command containing box, search for tools.external
- Find the correct Tools.ExternalCommandX where X matches the order of your tool in the external tools list, for instance 4.
Assign shortcut keys to your command and press Ok. I use Alt+E.
Next up, we need to use the helpful Visual Studio extension ReAttach. Download and install it. It helps us reattach to the same w3wp process over and over again :-) I've written about ReAttach and debugging before.
Finally, let's assign some shortcut commands to Attach to process and reattach:
Using the same technique as last time:
- Search for Debug.AttachtoProcess and assign Alt+W
- Search for Debug.ReAttach and assign Alt+Q
Now you can first find your correct process under Alt+E, then attach to it using Alt+W and finally reattach using Alt+Q.
Maybe you want different shortcuts, feel free to do it your way.