如何配置 VSCode 任务以在集成终端中运行 powershell 脚本 [英] How to configure a VSCode Task to run a powershell script in the integrated terminal
本文介绍了如何配置 VSCode 任务以在集成终端中运行 powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以这样的方式,它不在子外壳中.我需要它来准备环境...设置环境变量.
In such a way that it is not in a sub shell. I need it to be able to prepare the environment...set environment variable.
"version": "0.1.0",
"command": "${workspaceFolder}/Invoke-Task.ps1",
/*"command": "powershell", creates subshell so doesn't work*/
"isShellCommand": false,
"args": [],
"showOutput": "always",
"echoCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "task1",
"args": ["task1"]
},
{
"taskName": "task2",
"args": ["task2"]
}
]
推荐答案
很抱歉,您没有正确编辑 .vscode/tasks.json
文件.
I am sorry, but you are not correctly editing the .vscode/tasks.json
file.
在您的场景中,假设您有一些想要作为 vscode 任务
运行的 powershell 脚本 ./scripts/mycustomPSscript.ps1
.对于这样的目标,请编辑任务文件,使其遵循以下示例:
In your scenario, lets say you have some powershell script ./scripts/mycustomPSscript.ps1
you want to run as a vscode task
. For such goal, edit the tasks file so it follows the below example:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run-some-custom-script",
"detail": "Prepare some ENV variables for the deployment",
"type": "shell",
"command": "./../scripts/mycustomPSscript.ps1",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
这篇关于如何配置 VSCode 任务以在集成终端中运行 powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文