Open mklement0 opened 6 years ago
Clarification: PowerShell on Unix-like platforms is already supported for VS Code's integrated terminal:
I'm using these settings to configure the integrated terminal to use PowerShell:
"terminal.integrated.shell.osx": "/usr/local/bin/powershell",
"terminal.integrated.shellArgs.osx": []
Without this setting VS Code doesn't know how to preprocess command line arguments correctly.
What you are asking for is to support the same for the "external terminal", e.g. the launch config setting "console": "externalTerminal"
.
Yes, this issue is about the external terminal (as noted in the "Steps to reproduce" section, but I've updated the description at the top to make that clearer).
It's more helpful to debug PowerShell itself in an external terminal, and using an external terminal is the default debug configuration in the PowerShell Core source-code repo.
Two asides:
The Powershell Core binary was renamed to pwsh
before the first public release (/usr/local/bin/pwsh
on macOS).
The need to override the default "terminal.integrated.shellArgs.osx"
value (suppress the -l
) will hopefully go away soon: https://github.com/PowerShell/PowerShell/issues/7704
Migrated and generalized from https://github.com/OmniSharp/omnisharp-vscode/issues/2605
It would be great if Visual Studio Code also supported a Unix configuration where PowerShell (Core) is configured as the user's default shell.
Below is an example of where that currently fails: when using an external terminal (as controlled by setting
console": "externalTerminal
) for debugging, the debugger-invocation command line assumes a POSIX-like shell on Unix, and submits a command using the latter's syntax, which breaks in PowerShell.There may be other, related cases.
In the debugger-invocation case, only a trivial tweak is required to support PowerShell too (see below).
Steps to reproduce
On a Unix-like platform with PowerShell Core installed, make the latter your default shell as follows:
chsh -s /usr/local/bin/pwsh
(macOS) orchsh -s /usr/bin/pwsh
(Linux).On Linux, reboot to make the new default shell take effect (not necessary on macOS).
Open any C# project in VS Code and debug with a
".NET Core Launch (console)"
configuration with setting"console": "externalTerminal"
Desired behavior
Debugger invocation should succeed.
Current behavior
Debugger invocation fails, because the command line sent to the terminal assumes POSIX-like-shell syntax (e.g.,
bash
), which PowerShell doesn't support.Sample symptom:
With a quoted path to
vsdbg
, the call would have to be prefixed with&
to make PowerShell happy.A pragmatic workaround would be not to quote the
vsdbg
path, which would make the call succeed in PowerShell too, without special-casing.This should be safe as long as the user's
$HOME
path has no embedded spaces - something I've never seen in the Unix world.