Vscode-powershell: Add option to launch and debug external powershell.exe

Created on 7 Feb 2017  路  7Comments  路  Source: PowerShell/vscode-powershell

Now that we have an attach option it would be really helpful to be able to
automate this process into an launch external console option

theoretically could this not simply be done by creating the powershell exe in a windowed mode then adding the attach functionality to add the debugger

the built in debugger is great but we lose all layer 2 interactive functionality like progress bars and message color

@@

Area-Debugging Issue-Enhancement

All 7 comments

Certainly a possibility. We could launch powershell.exe to run a specific script and then auto-attach to it with the debugger.

I would love to see this feature!
Coming from PowerGUI, I was very fond of the "Run in External PowerShell Window" and the Script Parameter input options.
Running externally eliminated the weird ISE-style issues, allowing me to see exactly what the end-user would see.
Allowing for Parameter input allowed me to see exactly how the script would handle itself when passed a simple string. Very neat.

I would love to see this as a possibility for allowing me to make full use of monitor real estate when working in VSCode on a multi monitor basis and also when travelling and using a single laptop monitor.

The scenario that I have in mind is that with this functionality this would also allow me to minimise the integrated console in VSCode and see full screen code when I'm working on a train or at a client site whilst allowing me to context switch to the PowerShell console as an overlay (using the console transparancy options) with presses of Alt+Tab easier than it currently is in the full experience within vscode or allow me to move all executed commands in the console on an additional monitor

The scenario above may have a dependency on functionality being requested in this issue https://github.com/Microsoft/vscode/issues/10121

As a further point the scenario detailed above is something that you can get in the ISE with ISESteroids like below which is extremely useful on trains etc when you only have a single screen to work with

image

So is this ever going to happen?

This would indeed be a great feature to have.

https://stackoverflow.com/a/57260486/45375 shows that the current workaround via the PowerShell Attach to Host Process launch configuration is

  • far from user-friendly

  • seem to work on _Windows_ only, and there only when attaching to a PowerShell _Core_ console.

@mklement0 thanks for your detailed write-up! One point of clarification-- as of PowerShell 6.2 attach to host process is available cross-platform due to the cmdlet Enter-PSHostProccess being available...we do understand that this could be more user friendly and are working on making this experience, with some changes being to PowerShell itself... the PR where we are working on this is here: https://github.com/PowerShell/PowerShell/pull/10189

Thanks for the update and the pointer to the PR, @SydneyhSmith.

as of PowerShell 6.2 attach to host process is available cross-platform due to the cmdlet Enter-PSHostProccess being available...

Not being familiar with Enter-PSHostProccess, I assume you mean that is being used behind the scenes and _should_ enable debugging via attaching to an external console on _all supported platforms_?

However, what I describe in the linked StackOverflow post for PowerShell Core works for me on Windows only.

On my macOS 10.14.6 machine with PowerShell Core 7.0.0-preview.2, I can _almost_ get it to work, but not quite:

On attaching, the debugger breaks in the PSConsoleHostReadLine function, as on Windows, but the breakpoints in my user code are never hit.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheDanishDynamo picture TheDanishDynamo  路  3Comments

keposet picture keposet  路  3Comments

bgelens picture bgelens  路  3Comments

rkeithhill picture rkeithhill  路  3Comments

guidooliveira picture guidooliveira  路  3Comments