You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow debug launch configurations to be added dynamically #10861
Today, when a C# .NET Core project is opened, the C# extension does a fair amount of work to generate a launch.json file (if none exists already) that matches the current settings in the project. However, if the user changes the launch configurations in their project it gets out-of-sync with launch.json. For C#, the duplication of launch configurations between launch.json and the project files adds a lot of complexity for the user. It might be a better experience for C# developers if the extension were able to provide debug launch configurations to VS Code dynamically when a project is opened or modified.
Reacted by Eric Erhardt, Livar, Zlatko Knezevic, Paris Qian and Damien LaRocque
Another possibility (which would help greatly with the PowerShell extension) would be to provide a way specify a command or function to be called in the language extension which could dynamically generate the parameters to send as part of launch.json. My language server holds some connection details that are unique for each VS Code window with the PowerShell extension active (TCP port numbers, etc). It'd be nice if the language server could provide that information to the debugger to be passed to the debug adapter without having to manipulate launch.json.
I was considering the option to update the launch.json directly for each session using the new configuration APIs but I'd feel a little bad having the user deal with edits to their checked-in launch.json file when they work in a repo shared with other develoeprs.
From the C# extension's perspective it would be easier to provide the launch configurations that we know about unless the launch.json already exists. If the launch.json is present, we would assume that the user is defining their own configurations and not provide any.
Our biggest concern in generating a launch.json is with user modifications. Today, we generate a launch.json for the user when we analyze their project for the first time. However, if the user changes their project, it's now up to them to keep the launch.json in sync. We could re-generate the launch.json, but we would want to detect whether the user has modified it first to avoid stomping on their changes.
As part of #9061 it is now possibly to modify the launch.json at any time through extension host code. Please try that out and let me know if something is missing for your scenarios - thanks!
Isidor Nikolic (@isidorn), if I understand the work correctly, this means that extensions now have an easier way to modify the launch.json file. This will definitely simplify some of the code we already have in the C# extension to generate that file. However, this particular issue was about being able to provide launch configurations programmatically (i.e. without modifying the file).
In our scenario, we already have all of the launch configuration information in the user's project files in a different format. Duplicating this information in a launch.json file and keeping it in sync when the user makes changes is a major headache. Unless I'm missing something, I don't think #9061 addresses our scenario.
Dustin Campbell (@DustinCampbell) are you aware that it is possible to do this and does that help with your scenario? This way you are passing a custom launch configuration to be used instead of modifying the underlying launch.json
Your extension can get activated on event 'onDebug:type' where type is 'node', 'cpp'. This happens once the user hits F5
vscode.commands.executeCommand('vscode.startDebug', 'myConfigName') should pick a configuration from the debug panel and start debugging that configuration
Isidor Nikolic (@isidorn) hmmm, so if an extension registers for onDebug:language, does that override the normal behavior for F5? If so, what gets invoked inside of the extension's code to take its place?
FWIW, this strikes me as a weird hoop to make extension authors jump through. Also, it's not clear to me how activating the extension on the onDebug:type event helps. I would expect that the C# extension would already be activated.
David Wilson (@daviwil) currently we only have limited support for this, an extension can be activiated onDebug:language. So it will not override the normal behavior of F5 but an extension can do additional things once it is activated. What you are looking for sounds to me like a new feature request. Dustin Campbell (@DustinCampbell) yes, this does not seem to help with your use case. I am not sure when you activate your c# extension, probably on first open of a c# file
Yes, you said this before, but I'm still not sure how this solves our scenario. Our extension doesn't execute the startDebug command. The user is the one pressing F5. Perhaps I'm missing something, but it's not clear to me at what point we can introduce a custom launch configuration. Could you please clarify?
Please note that this is startSessionCommandnot startDebug I made a typo in the previous comment, this is a new feature which we support for the last couple of milestone
Activity
daviwil commentedon Sep 16, 2016
Another possibility (which would help greatly with the PowerShell extension) would be to provide a way specify a command or function to be called in the language extension which could dynamically generate the parameters to send as part of launch.json. My language server holds some connection details that are unique for each VS Code window with the PowerShell extension active (TCP port numbers, etc). It'd be nice if the language server could provide that information to the debugger to be passed to the debug adapter without having to manipulate launch.json.
I was considering the option to update the launch.json directly for each session using the new configuration APIs but I'd feel a little bad having the user deal with edits to their checked-in launch.json file when they work in a repo shared with other develoeprs.
DustinCampbell commentedon Sep 16, 2016
From the C# extension's perspective it would be easier to provide the launch configurations that we know about unless the launch.json already exists. If the launch.json is present, we would assume that the user is defining their own configurations and not provide any.
Our biggest concern in generating a launch.json is with user modifications. Today, we generate a launch.json for the user when we analyze their project for the first time. However, if the user changes their project, it's now up to them to keep the launch.json in sync. We could re-generate the launch.json, but we would want to detect whether the user has modified it first to avoid stomping on their changes.
isidorn commentedon Sep 20, 2016
As part of #9061 it is now possibly to modify the launch.json at any time through extension host code. Please try that out and let me know if something is missing for your scenarios - thanks!
DustinCampbell commentedon Sep 20, 2016
Isidor Nikolic (@isidorn), if I understand the work correctly, this means that extensions now have an easier way to modify the launch.json file. This will definitely simplify some of the code we already have in the C# extension to generate that file. However, this particular issue was about being able to provide launch configurations programmatically (i.e. without modifying the file).
In our scenario, we already have all of the launch configuration information in the user's project files in a different format. Duplicating this information in a launch.json file and keeping it in sync when the user makes changes is a major headache. Unless I'm missing something, I don't think #9061 addresses our scenario.
isidorn commentedon Sep 20, 2016
Dustin Campbell (@DustinCampbell) thanks for claryfing -> reopening this
isidorn commentedon Sep 20, 2016
Dustin Campbell (@DustinCampbell) are you aware that it is possible to do this and does that help with your scenario? This way you are passing a custom launch configuration to be used instead of modifying the underlying
launch.jsonDustinCampbell commentedon Sep 20, 2016
I'm aware of that, but as I understand it, there are limitations:
isidorn commentedon Sep 20, 2016
vscode.commands.executeCommand('vscode.startDebug', 'myConfigName')should pick a configuration from the debug panel and start debugging that configurationDustinCampbell commentedon Sep 20, 2016
'cpp'? Is that a typo? This is the C# extension I'm referring to.
isidorn commentedon Sep 20, 2016
You can put any type you want there, go, php, c# - whatever debug type your C# extension registers
daviwil commentedon Sep 20, 2016
Isidor Nikolic (@isidorn) hmmm, so if an extension registers for
onDebug:language, does that override the normal behavior for F5? If so, what gets invoked inside of the extension's code to take its place?DustinCampbell commentedon Sep 20, 2016
FWIW, this strikes me as a weird hoop to make extension authors jump through. Also, it's not clear to me how activating the extension on the
onDebug:typeevent helps. I would expect that the C# extension would already be activated.isidorn commentedon Sep 21, 2016
David Wilson (@daviwil) currently we only have limited support for this, an extension can be activiated
onDebug:language. So it will not override the normal behavior of F5 but an extension can do additional things once it is activated. What you are looking for sounds to me like a new feature request.Dustin Campbell (@DustinCampbell) yes, this does not seem to help with your use case. I am not sure when you activate your c# extension, probably on first open of a c# file
DustinCampbell commentedon Sep 22, 2016
The is activated on a handful of events, but primarily
onLanguage:csharp, which is defined as.csand.csxfiles.isidorn commentedon Apr 13, 2017
This is supported now by the startDebug action
Example how the node debug is generating a configuration dynamically can be found here https://github.com/Microsoft/vscode-node-debug/blob/master/src/node/extension.ts#L364
DustinCampbell commentedon Apr 13, 2017
Yes, you said this before, but I'm still not sure how this solves our scenario. Our extension doesn't execute the startDebug command. The user is the one pressing F5. Perhaps I'm missing something, but it's not clear to me at what point we can introduce a custom launch configuration. Could you please clarify?
isidorn commentedon Apr 13, 2017
I am explaining it in this comment microsoft/vscode-go#745 (comment)
Please note that this is
startSessionCommandnotstartDebugI made a typo in the previous comment, this is a new feature which we support for the last couple of milestoneAlso here https://github.com/Microsoft/vscode-docs/blob/master/release-notes/v1_9.md#debugger-extension-authoring
DustinCampbell commentedon Apr 13, 2017
Thanks, I'll take a look.