1

How I can define a variable with extension scope, and the same can be used in task.json.

It's like I can set the value of SelectedAppId variable and the variable I can use in task.json

        {
            "name": "Debug (Development)",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000/$(<Config>.<ExtensionName>.<VarialbeName>)",
        }
1
  • do you want to be able to use a setting as the result of a variable in task.json? Can you give an example of the settings you like to use? Where is this SelectedAppId defined? Please give a full example of what you want to configure in which files. Commented Sep 2, 2020 at 20:45

2 Answers 2

3

VS Code doesn't provide a way to make arbitrary ${} style variables for tasks.json and launch.json, but your extension can define a setting and reference it as ${config:myExtensionsNewSetting}: https://code.visualstudio.com/docs/editor/variables-reference#_configuration-variables Alternatively, you can use an environment variable: https://code.visualstudio.com/docs/editor/variables-reference#_environment-variables

Sign up to request clarification or add additional context in comments.

Comments

1

You can implement a Command in your extension and register it with a name, e.g. "my_extension_id.variable_name". Now you can access the command with this syntax: ${command:my_extension_id.variable_name} For details please see: https://code.visualstudio.com/docs/editor/variables-reference#_command-variables

Comments

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.