为 2.0.0 写入 VSCode runner v0.1.0

Write VSCode runner v0.1.0 for 2.0.0

这是直接在 VS Code 中的 runner 到 运行 代码,但是是为 v0.1.0 编写的,我找不到版本 v2.0.0 的等效代码。

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "python",
    "isShellCommand": true,
    "args": ["${file}"],
    "showOutput": "always"
}

VS Code 文档在此处提供了相关说明:Migrating to Tasks 2.0.0

Here is a migration guide:

  • taskName: Use the label property instead.
  • isShellCommand: Use the "type": "shell" property instead.
  • ...
  • showOutput: Use the "presentation" : { "reveal": "..." } property instead.
  • ...

argscommand不变。此外,您现在应该创建一个 tasks: [] 数组,而不是单级结构,并且每个 task.

都有单独的配置

您的 v0.1.0 tasks.json 配置迁移到 v2.0.0 现在是:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "run-my-python-script",
            "type": "shell",
            "command": "python",
            "args": [
                "${file}"
            ],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            },
            "problemMatcher": []
        }
    ],
}

其中 "label" 可以是任何东西,只是为了识别任务:

Tasks.

的 VS Code 文档中讨论了所有其他配置