PowerShell debugging in Visual Studio Code: “PowerShell: Launch Current File w/Args” configuration template is missing
Posted by jpluimers on 2022/03/09
Not sure why, but most of my Visual Studio configurations have the “PowerShell: Launch Current File w/Args
” debug configuration template. So here is the JSON you need to add in your launch.json
configuration file.
{ "type": "PowerShell", "request": "launch", "name": "PowerShell Launch Current File w/Args Prompt", "script": "${file}", "args": [ "${command:SpecifyScriptArgs}" ], "cwd": "${file}" }
The trick is the bold part that prompts Visual Studio for the arguments.
Note: in order to have such a file, you need to have opened a folder in Visual Studio Code first, then open a PowerShell script file from that directory second.
Related:
- [WayBack] PowerShell Parameters – PowerShell – SS64.com
- [WayBack] Passing Arguments to vscode-powershell · Issue #965 · PowerShell/vscode-powershell · GitHub
- [WayBack] Tahir Hassan’s Blog: PowerShell/VSCode: Debugging a script which has parameters
- [WayBack] “PowerShell Launch Current File w/Args Prompt” does not work when VS Live Share extension is enabled · Issue #1332 · PowerShell/vscode-powershell · GitHub
- [WayBack] initial commit · PSVortex/Powershell@944a90a · GitHub
- [WayBack] On non-Windows, the debug command line expects a `sh` compliant shell · Issue #81399 · microsoft/vscode · GitHub
- [WayBack] PowerShell – Not running the PowerShell script. What is the error? – Helperbyte
–jeroen
Leave a Reply