Home > Blockchain >  vscode debugging: launch program prior to attaching to it
vscode debugging: launch program prior to attaching to it

Time:02-17

I am developing a plugin for some program in C#. In order to debug my plugin, I need to

  1. start the program,
  2. attach the debugger to the program.

How do I do 1.?

My launch.json looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "net48",
            "type": "clr",
            "request": "attach",
            "processName":"sldworks.exe",
        }
    ]
}

When I start debugging, I get the (expected) message that no process with the specified name was found.

So I tried adding

"preLaunchTask": "C:\myPath\sldworks.exe"

into the configuration, but then VScode says

Could not find the task 'C:\myPath\sldworks.exe'.

I double-checked that the path is correct, and if I copy it into cmd and hit ENTER, the program starts.

CodePudding user response:

With @DavidG's hint I was able to figure it out. I had some issues with spaces in the command but was able to resolve this as well.

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "net48",
            "type": "clr",
            "request": "attach",
            "processName":"sldworks.exe",
            "preLaunchTask": "runSwx"
        }
    ]
}

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "runSwx",
            "type": "shell",
            "command": "C:/'Program Files'/'SOLIDWORKS Corp'/SOLIDWORKS/sldworks.exe"
        }
    ]
}
  • Related