Vscode-powershell: Hitting a breakpoint in the console while not debugging should activate the VS Code debugger

Created on 24 Mar 2017  路  5Comments  路  Source: PowerShell/vscode-powershell

Desired behavior:

  1. Open a .ps1 file and set breakpoints using Set-PSBreakpoint -Script <script> -Line <##>
  2. Run the script from the console by invoking with its script name
  3. PowerShell hits the breakpoint, activates VS Code's debugger, then shows the breakpoint hit at that line

This should also work for command and variable breakpoints.

Issue-Enhancement

Most helpful comment

That one is tricky because VS Code's debugger model doesn't give me information about breakpoints until the user starts the debugger. I've asked them about this already but we haven't come to a viable solution yet. It's the last step in making a 100% compatible debugging experience between VS Code and the ISE, so I definitely want to get it working!

All 5 comments

Will this also work with breakpoints set from the editor?

That one is tricky because VS Code's debugger model doesn't give me information about breakpoints until the user starts the debugger. I've asked them about this already but we haven't come to a viable solution yet. It's the last step in making a 100% compatible debugging experience between VS Code and the ISE, so I definitely want to get it working!

It doesn't work for me (or I'm failing to understand how it's supposed to work).

Steps to Reproduce:

  1. Create new module: Answer.psm1
  2. Add function to module:
    ```posh
    function Get-Answer {
    42
    }
3. Open module in VS Code
4. Set breakpoint by pressing <kbd>F9</kbd> on `42`
5. Import module via `PowerShell Integrated Console`:
```posh
Import-Module -Path .\Answer.psm1
  1. Execute Get-Answer function from PowerShell Integrated Console:
Get-Answer
  1. Notice, that breakpoint doesn't trigger.

I've also tried sourcing *.ps1 file with function, but it doesn't trigger the breakpoint either. I can trigger breakpoint by running script file with F5 and then executing function from console, but I can't do this for module. It throws Cannot run a document in the middle of a pipeline error.

Details

  • VSCode Version: Code 1.15.1 (41abd21afdf7424c89319ee7cb0445cc6f376959, 2017-08-16T18:07:25.676Z)
  • OS Version: Windows_NT x64 6.3.9600
  • Extensions:

Extension|Author (truncated)|Version
---|---|---
PowerShell|ms-|1.4.1

I'm using the below combination and it seems that the above feature (launching from Integrated Console expecting breakpoint to be hit) only works if you manually start then stop the debugger (by hitting F5) for at least once. Is it by design or am I missing some options?
Also seems that when a breakpoint is removed, it still triggers for another time when launching script from Integrated Console. This doesn't happen by hitting F5.
And sometimes breakpoints stop triggering again and needs an F5...
The feature is handy when debugging with pipeline inputs. And ISE handles it well when launching from its Integrated Console. But ISE... ugh...

Version: 1.36.1
Commit: 2213894ea0415ee8c85c5eea0d0ff81ecc191529
Date: 2019-07-08T22:59:35.033Z
Electron: 4.2.5
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

@changbowen you are not missing anything--that is a limitation of this debugging experience today where you must hit F5 at least once

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pcgeek86 picture pcgeek86  路  4Comments

TheDanishDynamo picture TheDanishDynamo  路  3Comments

GQnzo picture GQnzo  路  3Comments

inthemedium picture inthemedium  路  3Comments

rkeithhill picture rkeithhill  路  3Comments