-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Shared properties in launch.json #53557
Comments
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding and happy coding! |
This would be a great feature to add to reduce the amount of duplicated configuration variables that are set in each of my launch configurations |
I disagree with this being a corner case. Any non-trivial development effort will sooner or later create the need for more than 1 configuration. |
Fighting redundancy is every programmers main task. I just entered my first .NET project and it have 5 configurations each ca 65 lines long. So this would be a great feature. Note: In each of our configurations we have an env property ca 40 lines long. So we would need some kind of defaultConfiguration.env as well :-) |
There multiply implementations possible, i personally don't like having only one defaultConfiguration, instead would be very useful to refer parent config by name, something like:
I understand that it requires some rules to merge json object, json arrays But it's definitely very useful feature, even some simplest implementation would help |
please reopen this. 90% of my |
This is definitely important. Not being able to share properties between configurations makes it look like I belive CMake Presets are a nice place to look for inspiration/directions about what kind of flexibility in the configuration specification would be reasonable do add, and what is expected of this functionality. |
Count me in as another interested person. I'm about to make multiple configurations that are identical apart from a single environment variable which makes me sad panda. |
Very interested too. |
I'm also interested. I recently switched to VS Code from Pycharm and it's a huge improvement, but this is one of the few things that I'm surprised hasn't been implemented unless I'm missing an obvious workaround. I think this would probably help with most people's workflows. In my case I have a single program but a different launch configuration for each of many flags that my program supports. My Some sort of inheritance from the workspace level (ideally with the ability to override) would probably reduce the complexity of my |
I also like the OP's idea to just have a default section in the |
how about adding a |
great, so all that's missing is the |
@Spongman please feel free to come up with a spec and implementation for the |
I'm going to leave that to the people that get paid to do such things. I half expect the "it's open-source, fix it yourself" mantra to come from the Linux crowd, but from Microsoft? Not so much... |
I see this is closed? It would be a very nice feature to add. I have about 25 environmental variables I specify for each of my launch configuration (x4). It would be nice to inherit a lot of these environmental variables from a base configuration. |
can we reopen this issue? |
I strongly recommend you guys consider reopen this. |
I agree this feature would be extremely useful. It would reduce the size of my launch.json file in one project by about 80% and make it faster and cleaner to add new targets. |
It will be nice to have the same kind of inheritance that we have in the CMakePresets.json |
Just give every config an optional i.e. [
{
"id": "foo",
"type": "node",
"request": "launch",
"name": "Parent",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/node_modules/.bin/index",
"env": {
"REGION": "...",
"ENVIRONMENT_NAME": "...",
"PROFILE_TABLE_NAME": "..."
},
"runtimeExecutable": "node",
},
{
"extends": "foo",
"env": {
"VALUE": "..."
}
}
] |
This would be a great feature, adding my support. |
Related on Stack Overflow: How can I reuse configuration parts VS Code launch configurations?. This also calls to mind CMake presets |
@TylerLeonhardt sorry for the ping but since @weinand is retired, who is the best contact to re-evaluate this issue for the backlog now that it has quite a few upvotes? |
For debug stuff it's either @connor4312 or @roblourens |
Why is this closed? While perhaps not top-priority, it's a simple enough optional feature to add, which would help reduce duplication in larger projects. The classic "don't duplicate code" rule holds true also for things like configs. |
I agree with pretty much every body else here. It would be an awesome feature to have. Here is my vote to re-open this issue. |
@connor4312 is this a candidate for reopening then? Sorry for the ping. |
Yea, this seems popular. |
any eta on this? i'm working a legacy c++ project and configurations mostly differ by arguments (it's actually DSL file) passed to application. |
This would be a tremendous addition to VS Code's debugger |
I got here from web searching how to reuse parts of configurations in I also happened to be working with some reusable GitHub Actions workflow and I thought that if the core idea of reusing workflows is working well for CI actions, it ought to be good enough for launch configs too. I.e. a This is how a made up sample {
"templates": [
{
"id": "run_with_mode",
"inputs": {
"run_mode": {
"description": "Whether to run fast or slow",
"required": false,
"type": "string",
"default": "fast"
}
},
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/bin/program",
"env": {
"MY_RUN_MODE": "${{ inputs.run_mode }}"
},
"args": ["--verbose"],
"preLaunchTask": "mage build",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"hideSystemGoroutines": true
}
],
"configurations": [
{
"name": "Run (Fast)",
"uses": "run_with_mode",
"with": {
"run_mode": "fast"
}
},
{
"name": "Run (Slow)",
"uses": "run_with_mode",
"with": {
"run_mode": "slow"
}
},
{
"name": "Run (Default)",
"uses": "run_with_mode"
}
]
} EDIT: Or maybe this is a bit overkill, and the idea of just letting a config refer to a previously defined config (as in #53557 (comment)) would be good enough. I'm just brainstorming some proposal ideas here. |
Some weeks ago I wrote vscode-workspace-gen, which basically takes a template as input and generates the *.code-workspace (or launch.json) files. The template itself is JSON, but allows for sharing objects instead of duplicating them. Only the generated files have the duplication. |
Just wanted to mention that most of this logic also applies to tasks in many cases: launch a process with slightly different params. So maybe tasks could be considered for this feature too. |
It's surprising that this simple feature is still open. |
@budaestew if it's so simple then you should PR it, otherwise those kind of comments are not helpful :) |
Search Terms
launch.json, configuration, url
Suggestion
The ability to specify shared properties among launch configurations.
Allowing properties to be inherited or specified in some common way while allowing overrides in individual entries would ease this situation greatly.
Use Cases
For example, I have many launch configurations that are identical except the URL. Management of changes then has to be propagated to each and every entry. Often a single launch.json can contain dozens of entries, and changing something simple but common like browser or other option must be done by search and replace. SNR itself is easy, but the repeated entries clutter up the launch.json and make spotting the actual differences when they exist other than URL more difficult.
I fully understand this is a corner case and not relevant to a large audience, however it would be extremely helpful for those who do need it, and the implementation is small in scope.
Examples
Not too picky about actual implementation, but a possible idea is below. Multiple shared configs accessed by name would be even better to allow multiple default settings.
The text was updated successfully, but these errors were encountered: