Setting up VScode to debug pwsh and Powershell scripts

Viewed 1006

I have been using vscode for developing/debugging my pwsh core scripts for a while. I normally work on windows, so I have set my default terminal to point to pwsh.exe, and my debugging experience is normally great. I still have a few scripts that use powershell 5/.net framework dependencies, and I would like to have a separate configuration that I can run to specify to use the windows powershell exe instead of the integrated terminal/pwsh.exe that I use as a default.

I have the PowerShell Extension installed, and in settings.json I have

"powershell.powerShellDefaultVersion": "pwsh 7"

If I change this to

"powershell.powerShellDefaultVersion": "Windows Powershell (x86)"

and hit F5, the extension will launch windows powershell like I would expect.

I would like to create a launch.json file that has configurations for both, so I can use my default pwsh as a default, and choose to use the windows powershell for specific scripts that I am working with.

I have tried adding console and program properties to the config template that vscode generates to point to the powershell.exe but they seem to be ignored.

example launch.json

{
     "name": "PowerShell: Launch Current File",
     "type": "PowerShell",
     "request": "launch",
     "script": "${file}",
     "cwd": "${file}",
     "program": "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
}
0 Answers
Related