Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I attach to a specific process in Visual Studio Code

When I debug my .net core project in VSC I'm asked for a process Id to attach to. This shows a long list of running processes where I either type or scroll to find a specific process. How can I attach to a specific same process each time I want to debug?

like image 234
ghoul Avatar asked Feb 27 '20 19:02

ghoul


People also ask

How do you attach a process in VS Code?

Select the attach configuration in the debug pane and click the Run button. Visual Studio Code will find all the processes it thinks it can attach to.

How do you attach a process?

In Visual Studio, select Debug > Attach to Process (or press Ctrl+Alt+P) to open the Attach to Process dialog box.


1 Answers

In visual studio code your debug options can be changed in the launch.json file. You can get to this file quickly through debug. Simply click the cog icon to open the json file.

Here you will see configurations for your setup.

"configurations": [
    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processId":"${command:pickProcess}"
    }
]

name refers to the option inside the debug dropdownlist.

Find the configuration using processId and change this to processName

processName is the process name to attach to. If this is used, processId should not be used.

The process name will be the .exe of the process id you'd normally be selecting. Once this change is made next time you debug on the option you will automatically attach to your specified process if it is running.

"configurations": [
    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processName":"someProcess.exe"
    }
]
like image 107
ghoul Avatar answered Oct 01 '22 01:10

ghoul