2

I want to add a shortcut-button in Visual Studio 2015. Clicking this button should just emulate "Attach To Process" -> Select "w3wp.exe" -> Attach. Does anyone know how to do it?

  • 1
    See http://blog.markvincze.com/attach-to-process-shortcut-in-visual-studio/ – Sergey Vlasov Feb 26 '16 at 04:58
  • Possible duplicate of [Attaching to a child process automatically in Visual Studio during Debugging](http://stackoverflow.com/questions/422768/attaching-to-a-child-process-automatically-in-visual-studio-during-debugging) – Gilles Feb 26 '16 at 13:54
  • I updated my answers with links to the Visual Commander extension and the code for the macro. I have also linked two other extensions that provide advanced capabilities for attaching to process and I think will fit what you are looking for. Let me know how that goes. – Gilles Mar 01 '16 at 12:59

1 Answers1

2

You can't do those two commands on one toolbar button click apart from creating or using an existing Visual Studio extension.

Creating a Visual Studio extension would be feasible but somewhat involved (as a complete project in itself).


Available Extensions:

  1. The first extension you could use is Visual Commander (detailed below) to create a Macro.
  2. Depending on your needs you could also use AttachTo which provide a one click option to attach to IIS.
  3. Finally there is also Debug Attach Manager which can attach to specific process and then remember it.


Using a macro to achieve the desired effect:

As mentioned by @Sergey Vlasov, you can can install a Visual Studio Extension named Visual Commander that brings back Macros in Visual Studio. Then you can program a macro to do this for you. The code for the macro comes from another SO answer

Public Sub AttachShortcut()
  For Each proc In DTE.Debugger.LocalProcesses 
    If proc.Name = "what you're looking for" Then
      proc.Attach()
      Exit Sub
    End IF
  Next
End Sub


Adding the shortcut button:

You can also easily add a button in your toolbar to add "Attach to Process..." if you prefer to have the button on your toolbar.

To do this go in the Menu under TOOLS. Then choose Customize.

There select the second tab "Commands".

The select Toolbar and choose the toolbar you want the button to appear in. For example "Debug" if you want it to appear during debugging.

Then press the Add Command... button and choose the Debug category. There you will find the Attach to Process.

This would make it more readily available if you prefer to use the toolbar.

Community
  • 1
  • 1
Gilles
  • 5,269
  • 4
  • 34
  • 66