如何 运行 仅在 vscode 中在 powershell 中执行特定任务
How to run a specific task in a powershell only in vscode
我在 windows 10,我在 vscode 中的默认 shell 是 git bash,它被所有任务使用。
对于特定任务,我想使用电源shell。这可能吗
{
"label": "sometask",
"type": "shell",
"command": "sam build",
"group": "test"
}
How to configure a VSCode Task to run a PowerShell script in the integrated terminal
Features In order to use this application, create a configuration file
in your .vscode directory. This file will define the available tasks.
For example, it could look something like:
{
"Task Name": {
"cmd": "ps", // The command you'd like to run in the terminal
"args": ["-a"], // Array of string arguments to the command
"stealFocus": true, // If this is true, focus will jump to the terminal right away
"shellOptions": {} // This allows you to override the default shell options described below for this specific task.
},
"Task 2:" {
"cmd": { // cmd and args can also vary based on platform, just like default shell.
"default": "vi",
"mac": "nano",
"linux": "emacs"
},
"args": {
"default": []
"mac": ["-B"]
}
}
}
对于以下工作。
https://code.visualstudio.com/docs/editor/tasks#_common-questions
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d", "/c"
]
}
}
},
...
接受的答案是使用 cmd,它没有解释它应该放在哪里,这适用于 PowerShell:
{
"version": "2.0.0",
"tasks": [
...,
{
"label": "Name",
"type": "shell",
"command": "Some Command",
"options": {
"shell": {
"executable": "powershell.exe"
}
}
}
]
}
我在 windows 10,我在 vscode 中的默认 shell 是 git bash,它被所有任务使用。
对于特定任务,我想使用电源shell。这可能吗
{
"label": "sometask",
"type": "shell",
"command": "sam build",
"group": "test"
}
How to configure a VSCode Task to run a PowerShell script in the integrated terminal
Features In order to use this application, create a configuration file in your .vscode directory. This file will define the available tasks.
For example, it could look something like:
{
"Task Name": {
"cmd": "ps", // The command you'd like to run in the terminal
"args": ["-a"], // Array of string arguments to the command
"stealFocus": true, // If this is true, focus will jump to the terminal right away
"shellOptions": {} // This allows you to override the default shell options described below for this specific task.
},
"Task 2:" {
"cmd": { // cmd and args can also vary based on platform, just like default shell.
"default": "vi",
"mac": "nano",
"linux": "emacs"
},
"args": {
"default": []
"mac": ["-B"]
}
}
}
对于以下工作。
https://code.visualstudio.com/docs/editor/tasks#_common-questions
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d", "/c"
]
}
}
},
...
接受的答案是使用 cmd,它没有解释它应该放在哪里,这适用于 PowerShell:
{
"version": "2.0.0",
"tasks": [
...,
{
"label": "Name",
"type": "shell",
"command": "Some Command",
"options": {
"shell": {
"executable": "powershell.exe"
}
}
}
]
}