Skip to content

Delay launch/attach until after config done #2250

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jborean93
Copy link
Contributor

@jborean93 jborean93 commented Jul 28, 2025

PR Summary

Updates the sequence of launching and attaching scripts until after
configuration done is received. This aligns the behviour of starting a
debug session with other debug adapters. A side effect of this change is
that it is now possible to set breakpoints and do other actions in an
attached runspace target during the initialisation.

Also adds a new option NotifyOnAttach for an attach request which will
create the PSES.Attached event before calling Debug-Runspace
allowing attached scripts to wait for an attach event.

PR Context

Fixes: #2191
Fixes: #2245

The changes here are based on what is in the PR #2248 as it requires the reflection based approach to set breakpoints on an attach scenario for WinPS.

PR to document new option in vscode-powershell PowerShell/vscode-powershell#5249.

Adds support for setting breakpoints in untitled/unsaved files for
Windows PowerShell 5.1. This aligns the breakpoint validation behaviour
with the PowerShell 7.x API so that a breakpoint can be set for any
ScriptBlock with a filename if it aligns with the client's filename.
Updates the sequence of launching and attaching scripts until after
configuration done is received. This aligns the behviour of starting a
debug session with other debug adapters. A side effect of this change is
that it is now possible to set breakpoints and do other actions in an
attached runspace target during the initialisation.

Also adds a new option `NotifyOnAttach` for an attach request which will
create the `PSES.Attached` event before calling `Debug-Runspace`
allowing attached scripts to wait for an attach event.
@jborean93
Copy link
Contributor Author

Also have opened PowerShell/PowerShell#25788 which adds an event and public API to determine when Debug-Runspace has attached itself to a Runspace. This will help provide an official public API for new PowerShell versions if attached but the proposed notifyAttach option here will be good for older PowerShell versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write event on configurationDone for attach requests Bring launch sequencing in line with DAP spec
1 participant