Friday, September 9, 2016

command line attach debugger to process

The one liner below will start debugging the IIS processes using Visual Studio. Instead of navigating to the menu using the mouse, Attach Process, check all processes, reverse sort process name, select all w3wp, attach.

(([System.Runtime.InteropServices.Marshal]::GetActiveObject("VisualStudio.DTE")).debugger.localprocesses | Where Name -Match "w3wp.exe").Attach()

This saves time, especially if you need to perform this action several times.

This could also be changed into a function

Function attachdebug

param ([Parameter(Mandatory=$true)][ValidateNotNull()]



(([System.Runtime.InteropServices.Marshal]::GetActiveObject("VisualStudio.DTE")).debugger.localprocesses | Where Name -Match $process).Attach()




attachdebug -Process w3wp.exe

No comments: