pez*_*nen 9 debugging visual-studio-code
Using Powershell ISE I often set breakpoints in a script and start the script from command line. ISE then stops at the breakpoint and lets me debug from there. How do I do the same from Terminal in Visual Studio Code? Below is a script just to show you what I mean. Starting from a terminal I would write:
.\hello.ps1 -firstName "firstName" -lastName "theLastName"
Run Code Online (Sandbox Code Playgroud)
But doing that from terminal it just starts a new window.
.\hello.ps1 -firstName "firstName" -lastName "theLastName"
Run Code Online (Sandbox Code Playgroud)
pjp*_*riv 19
为了使Eickhel Mendoza的链接中的信息变得明确,解决方案是设置一个运行和调试配置文件。这是创建于.vscode/launch.json
. 本案例的内容是:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Hello Script",
"type": "PowerShell",
"request": "launch",
"script": "${workspaceFolder}\\hello.ps1",
"cwd": "${workspaceFolder}",
"args": ["-firstName \"firstName\" -lastName \"theLastName\""]
}
]
}
Run Code Online (Sandbox Code Playgroud)
然后只需打开 VSCode 上的“运行和调试”侧边栏窗格(带有 bug 或Ctrl+ Shift+的播放按钮D),您可以在其中运行启动脚本,并且您设置的任何断点都将按预期命中。
小智 5
也许这可能会有所帮助...它涉及修改工作区中的 launch.json 文件。
https://github.com/PowerShell/vscode-powershell/tree/master/examples#passing-arguments-to-the-script
归档时间: |
|
查看次数: |
7177 次 |
最近记录: |