Is there a way to launch a debugger with a set up launch,.json from inside a vscode task.json?

43 Views Asked by At

I currently have a few steps of tasks chained together that builds and deploys a server for my Java application. Currently, I can run the debugger either by:

  1. Selecting the debugger from the dropdown list in the debugger tab, or
  2. From the command palette by selecting debug > my_debugger

But these are just workarounds and I would like to streamline my whole workflow using a single vscode task.

The last step I need to figure out is if I can launch a debugger from inside of a tasks.json, instead of using the 2 methods mentioned above.

I've gotten as far as defining a task:

"tasks": [
    {
        "label": "LAUNCH DEBUGGER",
        "type": "process",
        "command": [
            "workbench.action.debug.selectandstart",
        ],
        "args": ["my_debugger"],
    },
],

But this only opens up a list of all of my debuggers from the command palette. Is it possible to make it automatically select a specific one from the list? Currently the arguments doesn't work as I would expect, as shown above.

I've also tried another method of using user inputs, but this doesn't work either:

"tasks": [
    {
        "label": "LAUNCH DEBUGGER",
        "type": "process",
        "command": [
            "${input:mydebuginput}",
        ],
    },
],
"inputs": [
    {
        "id": "mydebuginput",
        "type": "command",
        "command": "workbench.action.debug.selectandstart", 
        "args": "my_debugger"
    }
]

I've tried reading the vscode docs on Debugging and Tasks separately, but haven't managed to find anything that connects the two in the way I need.

I have also seen stuff on adding preLaunchTasks inside the launch.json but this won't work for what I need unfortunately.

0

There are 0 best solutions below