$PSVersionTable:Major Minor Build Revision
----- ----- ----- --------
1 5 1 0
[email protected]
[email protected]
[email protected]
Name Value
---- -----
PSVersion 6.0.0-rc.2
PSEdition Core
GitCommitId v6.0.0-rc.2
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name Value
---- -----
PSVersion 5.1.16299.98
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.98
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I am experiencing a problem with setting a function breakpoint and using the VS Code debugger. The issue occurs in both PS Core 6 RC2 and PS 5.1.
Example code:
1..10 | ForEach-Object {Write-Host "Hello World"}
Create a function breakpoint for Write-Host:

will produce the following error on PS Core 6 when starting the debugger. (PS 5.1 does not produce error text)
An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled Exception: 1..10 | ForEach-Object {Write-Host "Hello World"}
System.ArgumentException: Unexpected breakpoint type: CommandBreakpoint
at Microsoft.PowerShell.EditorServices.BreakpointDetails.Create(Breakpoint breakpoint)
at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Hit Command breakpoint on 'Write-Host'
PowerShell Core 6 RC2

PowerShell 5.1

Can you save the file to disk and try again. Right now, setting breakpoints won't work for "in-memory" files. That said, we should fix the PSES crash.
Same problem after saving to disk. I should have mentioned that in the original description, although I think the logs were from a non-saved.
Doh! :-)
I can reproduce the error with any saved file. For example opening DebugTest.ps1 which ships as an example as part of the VS Code PowerShell extension. Create a function breakpoint for Write-Host and it will blow up with the same error:

Here are the logs for this one:
DebugLogs2.zip
Thanks for this report, @jonathanmedd!
@rkeithhill: I didn't see too much in the logs but that exception he supplied seems like a good start, would you agree?
@tylerl0706 looks like this line
needs to be updated to check for CommandBreakpoint and VariableBreakpoint and create either CommandBreakpointDetails or VariableBreakpointDetails
I've been having the exact same issue (on windows and mac), posted previously with no resolution, has this been root caused or a fix made available yet ?
I've got a fix in the works for this. In the process I found another issue - I think with VSCode's debug protocol. There is a BreakpointEvent that allows the debug adapter to notify VSCode about line breakpoints changes that occur in the debug adapter. I see no equivalent for function breakpoint changes.
I could be missing something in the debug protocol spec but just in case, I've raised an issue with the VSCode folks.
At the very least, this will eliminate the crash when using a function breakpoint.
And it turns out the debug protocol is missing this capability - https://github.com/Microsoft/vscode-debugadapter-node/issues/157
So, in the case of the user creating a command breakpoint in PSIC, I'll not have that send a BreakpointEvent to VSCode.
The fix for this should be in the upcoming 1.6.0 release.
Most helpful comment
The fix for this should be in the upcoming 1.6.0 release.