几个"build tasks" for visual studio代码(python)
Several "build tasks" for visual studio code (python)
我的 tasks.json 看起来像这样:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// A task runner that runs a python program
"command": "python3",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"args": [
"${file}"
]
}
当我 运行 ctrl+shift+B
顶部面板询问 "Select the build task to run" 时,有 一个 选项:python3
。现在,如果我想添加一个新的构建任务(例如带有 scrapy 的 runspider
命令),那么它将被添加到构建任务中。我将如何添加这个?
您可以在 tasks.json
中定义多个任务,方法是将一组任务对象分配给任务 属性,如下所示:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
}
此外,Ctrl+Shift+B 运行s 默认构建任务,因此您可能需要设置 "workbench.action.tasks.runTask"
键绑定。
{
"key": "ctrl+shift+b",
"command": "workbench.action.tasks.runTask"
}
完成后,使用workbench.action.tasks.runTask
命令即可select任务,如下图:
您还可以通过在任务上设置 "group"
属性 来选择默认构建任务。此处,在以下代码段中,您的 "python3"
任务将 运行 作为默认构建任务。
...
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
...
您可以在此处阅读有关任务的更多信息:Tasks in VSCode
我的 tasks.json 看起来像这样:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// A task runner that runs a python program
"command": "python3",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"args": [
"${file}"
]
}
当我 运行 ctrl+shift+B
顶部面板询问 "Select the build task to run" 时,有 一个 选项:python3
。现在,如果我想添加一个新的构建任务(例如带有 scrapy 的 runspider
命令),那么它将被添加到构建任务中。我将如何添加这个?
您可以在 tasks.json
中定义多个任务,方法是将一组任务对象分配给任务 属性,如下所示:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
}
此外,Ctrl+Shift+B 运行s 默认构建任务,因此您可能需要设置 "workbench.action.tasks.runTask"
键绑定。
{
"key": "ctrl+shift+b",
"command": "workbench.action.tasks.runTask"
}
完成后,使用workbench.action.tasks.runTask
命令即可select任务,如下图:
您还可以通过在任务上设置 "group"
属性 来选择默认构建任务。此处,在以下代码段中,您的 "python3"
任务将 运行 作为默认构建任务。
...
"tasks": [
{
"taskName": "python3",
"type": "shell",
"command": "python3",
"args": [
"${file}"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"taskName": "runspider",
"type": "shell",
"command": "runspider"
}
]
...
您可以在此处阅读有关任务的更多信息:Tasks in VSCode