Vscode-powershell: ISE like breakpoint behaviour (hit breakpoints when running a script from the integrated terminal)

Created on 29 Aug 2019  路  3Comments  路  Source: PowerShell/vscode-powershell

Support for hitting breakpoints set in scripts run from the integrated powershell terminal

One of the main features of the Powershell ISE for me was that I was able to just open any script, set breakpoints and run the script from the ISE console and the breakpoints would be hit. Heck even breakpoints in scripts or modules that were invoked by that script would hit.

In VS Code, I find it extremely tedious to always have to edit launch.json just to change parameters I run a script I'm developing with. I'm still exclusively using ISE for script development, just for this one missing feature in VS Code.

I tried multiple times to switch to VS Code, because I really like it overall, but I'm always going back to ISE because I can't bear the overly complicated debugging setup.

Maybe I'm missing something, I really wonder why apparently no one else requested this.

What I want to happen

I want to open any .ps1 file in VS Code, set breakpoints in that file, then go to the terminal window, and invoke that script, or any script that indirectly calls the opened file, and the breakpoints I set in the file get actually hit, as if I used F5.

Area-Debugging Issue-Enhancement

Most helpful comment

You can't quite do what you want because (I believe) debug sessions have to be started from VSCode. However, if you add the PowerShell Interactive Session debug config, you can start debugging with that configuration and then run scripts from the PowerShell Integrated Console and breakpoints will be hit. You can even set breakpoints from the PSIC when debugging using the PowerShell Interactive Session debug config and those breakpoints will be hit. The nice thing about that debug config is that it doesn't require any customization. Just add it to your workspace's launch config.

All 3 comments

Looking at the underlying code, setting the breakpoint should just be calling Set-PSBreakpoint under the hood (which if you do directly does exactly what you want it to do).

But I'm also seeing the behaviour you describe. I'll try and look into it and see what would need to be done to enable this.

We are currently reworking the PowerShell extension, including the debug adapter, so while we might not be able to make this work immediately, it's likely something that will see some love in the medium term.

You can't quite do what you want because (I believe) debug sessions have to be started from VSCode. However, if you add the PowerShell Interactive Session debug config, you can start debugging with that configuration and then run scripts from the PowerShell Integrated Console and breakpoints will be hit. You can even set breakpoints from the PSIC when debugging using the PowerShell Interactive Session debug config and those breakpoints will be hit. The nice thing about that debug config is that it doesn't require any customization. Just add it to your workspace's launch config.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daviwil picture daviwil  路  4Comments

rkeithhill picture rkeithhill  路  3Comments

inthemedium picture inthemedium  路  3Comments

TheDanishDynamo picture TheDanishDynamo  路  3Comments

lukegriffith picture lukegriffith  路  3Comments