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
Startup script for temporary interactive console debug sessions #1168
As it stands, debugging a module in VSCode is still a bit clunky. Debug configurations allow for generating a temporary integrated console for every debug session, but using this option requires manually importing the module every debug session.
There is also the option of running a script via the script attribute in a debug configuration entry, which could potentially be used to run environment setup (module import, etc.) - however, the integrated console closes once the script completes. It would be helpful if there was a way to specify a startup script for temporary consoles in a debug configuration, so module imports and whatnot could be done automatically.
After speaking with @seeminglyscience on the PowerShell Slack team, it sounds like most of the work needed for this would be on the PSES side - however, I'm having trouble figuring out specifically what would need to be implemented on the PSES side vs. what would need to be implemented here.
There is already a startup script Microsoft.VSCode_profile.ps1 . It just is a user thing instead of a workspace thing. Given the way the PSIC works now, any sort of "startup" only needs to be run once because the language session and all debug sessions share the same PowerShell instance. You can see this with $pid in the PSIC at various phases of its use. Unless you are using temp integrated consoles, which disappear before you get a chance to check your output. :-(
That said, I do think it would be nice to have a workspace specific startup script or maybe even a workspace profile. The downside to a startup script is that we'd need to make that a setting and then we'd need to pass the path to the startup script from the extension to PSES (not a big downside mind you). If we made it a profile, it would have a specific name and if it existed it would just get run with no need to specify any extension setting. Either way, at this time, the default behavior would be that it runs once, when PSES first starts.
For a temp integrated console, perhaps a workspace profile could access variables to let you know which debug launch config is currently active. This is where I dither a bit. Is it easier to have a single workspace profile that could tell the diff between lang/debug sessions and know which debug config (name?) is active and then put all your logic in there to handle different debug scenarios. Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.
I believe he's talking mostly about temporary interactive debugging sessions which is where an init script would be the most helpful.
Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.
That was my thought. I can see that potentially being useful for all debug configuration types, but in particular temp interactive sessions. Assuming that's a reasonably easy property to add, I think that's the best way to go.
About workspace profiles, I really like the idea of them for preparing intellisense/loading editor commands from #190. I think mixing debugging into that, or having a separate profile for it might be confusing.
I think mixing debugging into that, or having a separate profile for it might be confusing.
Well for the vast majority of folks that will not discover the temp int console setting, such a profile would mix with debugging. Maybe that setting should be a setting on the launch configuration instead - at least for configs like launch script, current file and current file w/args. We also really, really need to fix the behavior that the temp console closes immediately after the script finishes.
changed the title [-]Startup script for interactive integrated console debug sessions[/-][+]Startup script for temporary interactive integrated console debug sessions[/+]on Jan 18, 2018
changed the title [-]Startup script for temporary interactive integrated console debug sessions[/-][+]Startup script for temporary interactive console debug sessions[/+]on Jan 18, 2018
Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.
This is what I think would be the easiest from a usability perspective - that, or re-use the current script attribute on debug configurations and add an attribute similar to PoSH's -NoExit switch.
I would also love to see this happen. Using the createTemporaryIntegratedConsole reduces the side effects from loading the module multiple times. I would love to also have some way to have it load the module into the temp console when I hit debug.
Now it seems that the temporary integrated console does not close after the script finishes which means it could be used as a startup script.
I'm using ms-vscode.powershell@2023.8.0.
Indeed, the console does not close, but the debugger stops, so it is not possible to debug when the script property is set. This is not due to the vscode-powershell plugin, but related to PowerShellEditorServices.
I was able to find a workaround by modifying a line of code in PowerShellEditorServices. I opened a discussion in their repository for interested people: PowerShell/PowerShellEditorServices#2180
Activity
hmmwhatsthisdo commentedon Jan 18, 2018
After speaking with
@seeminglyscienceon the PowerShell Slack team, it sounds like most of the work needed for this would be on the PSES side - however, I'm having trouble figuring out specifically what would need to be implemented on the PSES side vs. what would need to be implemented here.rkeithhill commentedon Jan 18, 2018
There is already a startup script
Microsoft.VSCode_profile.ps1. It just is a user thing instead of a workspace thing. Given the way the PSIC works now, any sort of "startup" only needs to be run once because the language session and all debug sessions share the same PowerShell instance. You can see this with$pidin the PSIC at various phases of its use. Unless you are using temp integrated consoles, which disappear before you get a chance to check your output. :-(That said, I do think it would be nice to have a workspace specific startup script or maybe even a
workspace profile. The downside to a startup script is that we'd need to make that a setting and then we'd need to pass the path to the startup script from the extension to PSES (not a big downside mind you). If we made it a profile, it would have a specific name and if it existed it would just get run with no need to specify any extension setting. Either way, at this time, the default behavior would be that it runs once, when PSES first starts.For a temp integrated console, perhaps a workspace profile could access variables to let you know which debug launch config is currently active. This is where I dither a bit. Is it easier to have a single workspace profile that could tell the diff between lang/debug sessions and know which debug config (name?) is active and then put all your logic in there to handle different debug scenarios. Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.
SeeminglyScience commentedon Jan 18, 2018
I believe he's talking mostly about temporary interactive debugging sessions which is where an init script would be the most helpful.
That was my thought. I can see that potentially being useful for all debug configuration types, but in particular temp interactive sessions. Assuming that's a reasonably easy property to add, I think that's the best way to go.
About workspace profiles, I really like the idea of them for preparing intellisense/loading editor commands from #190. I think mixing debugging into that, or having a separate profile for it might be confusing.
rkeithhill commentedon Jan 18, 2018
Well for the vast majority of folks that will not discover the temp int console setting, such a profile would mix with debugging. Maybe that setting should be a setting on the launch configuration instead - at least for configs like launch script, current file and current file w/args. We also really, really need to fix the behavior that the temp console closes immediately after the script finishes.
[-]Startup script for interactive integrated console debug sessions[/-][+]Startup script for temporary interactive integrated console debug sessions[/+][-]Startup script for temporary interactive integrated console debug sessions[/-][+]Startup script for temporary interactive console debug sessions[/+]hmmwhatsthisdo commentedon Jan 18, 2018
Keith Hill (@rkeithhill), Patrick Meinecke (@SeeminglyScience): I totally neglected to mention I was talking about the temporary interactive console - whoops! I'm editing the issue text now.
This is what I think would be the easiest from a usability perspective - that, or re-use the current
scriptattribute on debug configurations and add an attribute similar to PoSH's-NoExitswitch.mud5150 commentedon Mar 6, 2019
I would also love to see this happen. Using the
createTemporaryIntegratedConsolereduces the side effects from loading the module multiple times. I would love to also have some way to have it load the module into the temp console when I hit debug.JustinGrote commentedon Apr 22, 2020
Sydney Smith (@SydneyhSmith) this should probably be reclassified to an enhancement.
mdgrs-mei commentedon Nov 12, 2023
Now it seems that the temporary integrated console does not close after the
scriptfinishes which means it could be used as a startup script.I'm using ms-vscode.powershell@2023.8.0.
jul-m commentedon Sep 21, 2024
Indeed, the console does not close, but the debugger stops, so it is not possible to debug when the
scriptproperty is set. This is not due to thevscode-powershellplugin, but related toPowerShellEditorServices.I was able to find a workaround by modifying a line of code in
PowerShellEditorServices. I opened a discussion in their repository for interested people: PowerShell/PowerShellEditorServices#2180