9

I can use input variables from launch.json in launch.json.

"configurations": [
  {
    ...
    "args": [${input:file_no}]
    "preLanuchTask": "runPreTasks"
    ...
  }
],
"inputs": [
  {
    "id": "file_no",
    "type": "promptString"
  }
]

Now, I want to get access to the same variable without entering input a second time in tasks.json.

{
  "version": "2.0.0",
  "tasks":[
    {
      "label": "runPreTasks",
      "type": "shell",
      "command": sh,
      "args": [
        "/path2script/scriptName.sh",
        "${input:file_no}"    // This does not work, without defining input again
      ]
    }
  ]
}

Is there a way to pass input variables from launch.json to tasks.json in vscode?

1 Answer 1

1

Following @rioV8 answer, I edited my json files as shown below:

launch.json:

"configurations": [
  {
    ...
    "args": [${input:file_no}]
    "preLanuchTask": "runPreTasks"
    ...
  }
],
"inputs": [
  {
    "id": "file_no",
    "type": "command",
    "command": "extension.commandvariable.promptStringRemember",
    "args": {
      "key": "lastnumber",
      "description": "Enter the number"
    }
  }
]

tasks.json:

{
  "version": "2.0.0",
  "tasks":[
    {
      "label": "runPreTasks",
      "type": "shell",
      "command": sh,
      "args": [
        "/path2script/scriptName.sh",
        "${input:file_no}"    
      ]
    }
  ]
  "inputs": [
    {
      "id": "file_no",
      "type": "command",
      "command": "extension.commandvariable.rememberPick",
      "args": { "key": "lastnumber" }
    }
  ]
}
Sign up to request clarification or add additional context in comments.

1 Comment

Give credit where credit is due and mark as answer the @rioV8 response, not your own. Your answer won't work out of the box if not first reading the true answerer. You can always point out this post on the comment sections to indicate what you did after reading the real answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.