Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreLaunchTask: support passing parameters from configuration to preLaunchTask #27157

Open
xinyanmsft opened this issue May 23, 2017 · 13 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality tasks Task system issues
Milestone

Comments

@xinyanmsft
Copy link

xinyanmsft commented May 23, 2017

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

@dbaeumer dbaeumer added feature-request Request for new features or functionality tasks Task system issues debug Debug viewlet, configurations, breakpoints, adapter issues labels May 26, 2017
@dbaeumer
Copy link
Member

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

@isidorn isidorn added this to the Backlog milestone Jul 3, 2017
@isidorn isidorn removed their assignment Jul 3, 2017
@stefansedich
Copy link

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

@CRodriguez-US
Copy link

CRodriguez-US commented Sep 10, 2019

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

@dbaeumer dbaeumer assigned alexr00 and unassigned dbaeumer Sep 11, 2019
@tboyce021
Copy link

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.

@MikaelElkiaer
Copy link

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?

@weinand
Copy link
Contributor

weinand commented Jan 30, 2020

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...).

@MikaelElkiaer
Copy link

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.

@nsgundy
Copy link

nsgundy commented May 4, 2020

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.

@CRodriguez-US
Copy link

Any word on this? This would still be incredibly helpful

@alexandre-perrin
Copy link

+1

@simdax
Copy link

simdax commented Sep 16, 2022

+1
It would help with multiple configuration.
e.g. building a cpp project, often requires to build with the configuration you want to launch. Repeating the arguments can be cumbersome, and inefficient.

@tvardero
Copy link

tvardero commented Dec 22, 2022

Have an idea how to implement this feature:

launch.json configurations: add field "preLaunchTaskInputs" of type {[taskInputName: string]: string}.
User can specify values to be used for inputs inside of preLaunchTask. For example, if your preLaunchTask has ${input:SelectColor}, you can add to your configuration:

"preLaunchTask": "Paint my car",
"preLaunchTaskInputs": {
  "SelectColor": "Pink"
}

And task will have it's input value already and will not prompt user.
If preLaunchTask does not have input with name of "SelectColor", then it is just ignored.

Also, prob would be cool to have something like ${defaultTasksInputValue:SelectColor} which will search for task input with name "SelectColor" and use it's default value. If default value is not specified, or if task is not found - fail execution.
As well as ${defaultLaunchInputValue:SelectColor}, if input belongs to launch.json file.

Examples:
launch json: https://pastebin.com/7Q0x4ZeP
tasks json: https://pastebin.com/pv6a2tEi

@dostalj12
Copy link

+1
I need that feature too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality tasks Task system issues
Projects
None yet
Development

No branches or pull requests