Launch.json config for debugging

Could somebody share the launch.json config which works for debugging with the powershell universal extension in VSCode?

Or is this maybe handeled by the extension itself?

Are you trying to debug a dashboard? If so, you can right click on the dashboard to attach the debugger to it.

image

Yes this works, however what I’m trying to solve is that once I enter the debug prompt for the runspace in breakpoint, I cannot issue any command. Or better said, they don’t return anything…

I see this too with PowerShell 5.1. I’m not seeing this with PowerShell 7. That said, this only happens in the VS Code extension and not with a PowerShell console directly. This looks like a bug in the PowerShell VS Code extension. I’ll file an issue for it.

PS C:\Users\adamr> enter-pshostprocess -id 20764
[Process:20764]: PS C:\Users\adamr\Documents> get-runspace

 Id Name            ComputerName    Type          State         Availability
 -- ----            ------------    ----          -----         ------------
  1 Runspace1       localhost       Local         Opened        Busy
  4 9eded098-594... localhost       Local         Opened        InBreakpoint
  6 RemoteHost      localhost       Local         Opened        Busy


[Process:20764]: PS C:\Users\adamr\Documents> debug-runspace 4
Debugging Runspace: 9eded098-594a-4d84-9ebe-57d3eda8084c
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.

Entering debug mode. Use h or ? for help.

At line:3 char:1
+ New-UDTypography -Text $Test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[DBG]: [Process:20764]: [9eded098-594a-4d84-9ebe-57d3eda8084c]: PS C:\src\universal>> get-variable

Name                           Value
----                           -----
$                              PS $($executionContext.SessionState.Path.CurrentLocation)>
?                              True
^                              [DBG]:
ApiUrl                         http://localhost:5000
args                           {}

I just opened an issue here: https://github.com/PowerShell/PowerShellEditorServices/issues/1369

Just for your information: it also does not work from PowerShell ISE (I tried this exactly to troubleshoot a VSCode or extension issue)

But I’m throwing a party! :partying_face: It works from a powershell console directly indeed! Thanks so much for the workaround. I can keep on trucking.

Unfortunately I can’t switch to powershell 7 yet, because I need VMWare PowerCLI to connect to v6.7 vCenters. Otherwise I would :slight_smile:

Thanks again, you guys are doing a fantastic job! I love the new version of the framework. Cheers.

1 Like