-
Notifications
You must be signed in to change notification settings - Fork 498
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
Debug PowerShell 5.1 Untitled Files Not Working #3391
Comments
Hi, please try the latest release (from yesterday) v2021.5.1. I see your comment here #3343 (comment). I cannot repro this on my Mac with PowerShell 7 and 2021.5.1. |
Unfortunately I have and it still does not stop on the breakpoint. This is with VS Code version 1.56.2 now. |
Can you try PowerShell 7? Just trying to narrow down the cause. |
I can't install it to try it right now, and we don't use anything past 5.1 since there's no good way to reliably make sure all client machines have it. Assuming my personal machine has the same issue I can try it later today and update this issue with my findings. |
As far as I know, debugging untitled files in PowerShell 5.1 is unsupported (at least, it's not working now, and hasn't worked since I started maintaining the extension based on bug reports). I would suggest using the new (currently only in Insiders) configuration setting to always prompt to save files when debugging if you're still using PowerShell 5.1: "[powershell]": {
"debug.saveBeforeStart": "allEditorsInActiveGroup"
} As per #3357 we no longer prompt to save untitled files. |
Okay, I could have sworn it had always worked in the past and was one of the nicer improvements over using ISE in that you could debug a quick test without having to leave junk files everywhere. If that is no longer the case and won't be continued then you may close this out,. The prompting to save files which changed (broke imo, it never used to have that behavior) where they included that particular setting to allow for it to be changed to 'nonUntitledEditorsInActiveGroup' so that it behaved like it has for years before that maybe changed how the debugger interacts with these files, some sort of conflict perhaps? The Powershell extension expects it to be saved now but it isn't since VS Code (with that setting) doesn't prompt to do so, and simply runs it instead. That setting is in production now as well, but we can't really move off of Powershell 5.1 since it is what comes with Windows. Unfortunately there is no reliable way to ensure that thousands of endpoints all have Powershell 7 when we run scripts against them, more so without adversely affecting certain environments. |
I think what happened was that upstream VS Code added behavior to prompt to save files, or in some way changed it such that it started happening. Later they added the configurable option
This is certainly a pain point I think the whole team would like to see addressed, as 5.1 is in development freeze (hence the existence of 6 and now 7), but we need a version of .NET Core that has a support lifecycle as long as the Windows support lifecycle in order to include PowerShell 7 on Windows by default. That's my understanding of the situation anyway. |
Windows PowerShell doesn't have the breakpoint APIs required to debug a file in memory like that. Those APIs were added in PS 7 and we added support for them in PowerShell/PowerShellEditorServices#1119. AFAIK, prior to that we never supported untitled file debugging. |
Issue Description
Porting an issue from here that was determined to be an extension issue specifically. Had previously created this issue but it was closed prematurely.
Unless my memory is incorrect, one of the biggest advantages to VS Code over ISE was that we used to be able to set breakpoints and debug Powershell files that were untitled and not saved yet.
With this version I've noticed that no longer works, I can set a breakpoint on an untitled tab and it does not stop, it simply runs the entire script without stopping.
Attached Logs
Follow the instructions in the README about
capturing and sending logs.
Environment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
The text was updated successfully, but these errors were encountered: