Vscode: PreLaunchTask: support passing parameters from configuration to preLaunchTask

Created on 23 May 2017  路  8Comments  路  Source: microsoft/vscode

Currently when invoking preLaunchTask, the only possible is the task name. It would be great if properties in the associated configuration can be passed to preLaunchTask.

Scenario:
I am writing a pre-launch task to automate remote node.js debugging. The pre-launch task will launch the node.js process remotely and establish a SSH tunnel (port forwarding) back to local computer. And then debugger connects to that forwarded port to start debugging.
The node.js debugger port is specified in launch.json file, and there is no good way for the pre-launch task to get the debugger port.

The problem can be solved if preLaunchTask can take parameters from the configuration. For example, tasks.json allow '$config.port' as args:

       {
            "command": "dotnet",
            "taskName": "prepareDebug",
            "suppressTaskName": true,
            "args": [ "/myhelper.dll", "debug", "start", "$config.port" ],
            "isBuildCommand": false,
            "showOutput": "always",
            "options": {
                "cwd": "${workspaceRoot}"
            }
        }

@isidorn @weinand

debug feature-request tasks

Most helpful comment

Has there been any movement on this one? something I just ran into and would make life much easier if it were available.

All 8 comments

This needs work on both end the debugger and the task framework.

Has there been any movement on this one? something I just ran into and would make life much easier if it were available.

This would help me a ton too. I want to be able to select an option in launch.json, and pass that option to the subsequent pre and post launch tasks. The way I have it set up now means that I have to choose the option 3 separate times

I'm also running into issues with this. I have a launch configuration that prompts for the IP address. It then has a preLaunchTask to do some preparation on the device but that task then has to prompt for the same IP address again.

Related to this:
How about having the cwd from the launch configuration automatically applied to its preLaunchTask when the task itself does not specify otherwise?
Is this possible somehow?

cwd is nothing that VS Code knows about. A debug extension owns the schema for its launch attributes and only some define cwd (and VS Code cannot make any assumptions about the semantics of cwd anyway; it can only guess...).

cwd is nothing that VS Code knows about. A debug extension owns the schema for its launch attributes and only some define cwd (and VS Code cannot make any assumptions about the semantics of cwd anyway; it can only guess...).

Thanks for clarifying.

I feel like I fell into the same trap as many do - difficulty with discerning where VSCode's responsibility ends and extensions' begins.

Currently looking at the same issue. Launch configuration that prompts for the target's IP address. I'd like to pass that IP address to a preLaunchTask (running prep on the target). Right now I have to type it in twice.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

villiv picture villiv  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

borekb picture borekb  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

NikosEfthias picture NikosEfthias  路  3Comments