【问题标题】:VScode debug mode shows "Could not find the specified task"VScode调试模式显示“找不到指定的任务”
【发布时间】:2020-08-26 19:20:14
【问题描述】:

尝试在 vscode 中启动 Debug 会话时,它会抛出关于找不到指定任务的错误。 我已经尝试过其他 SO 问题的解决方案,例如 this,但没有成功。

launch.json:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
      ...
    },
    {
        "name": "MSEventHubs_Audit",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/audit-events.py",
        "console": "integratedTerminal",
        "args": [
            "config/config.ini",
        ],
        "envFile": "${workspaceFolder}/.env",
        "env": {"PYTHONPATH": "${workspaceRoot}"},
        "justMyCode": false,
        "preLaunchTask": {
            "task": "audit_tunnel"
        }
    },
    {
     ...
    },
]
}

tasks.json:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"command": "",
"args": [],
"tasks": [
    {
        "label": "activate_key",
        "type": "shell",
        "command": "smartOS_card_pin.sh",
        "args": [
            "${inputs:cardos_pass}"
        ],
        "group": "build",
    },
    {
        "label": "audit_tunnel",
        "type": "shell",
        "group": "build",
        "command": "ssh",
        "args": [
            "-NL",
            "port1:127.0.0.1:port2",
            "my_host"
        ],
        "dependsOn": "activate_key"
    },
    {
      ...
    }
],
"inputs": [
    {
    "id": "cardos_pass",
    "type": "promptString",
    "password": true
    }
]
}

我已经看了一段时间,无法弄清楚我做错了什么。 vscode 知道我的任务的证据是出现弹出消息时

我点击“配置任务”,“audit_tunnel”作为编辑选项出现。

我错过了什么?

【问题讨论】:

  • 我会从你的 tasks.json 顶部删除 "command": "", "args": [], - 这看起来像以前的语法。见code.visualstudio.com/Docs/editor/tasks#_migrating-to-tasks-200。其次,如果你自己运行audit_tunnel,能找到吗?你可以在里面放一个 echo 让它变得简单。
  • 是的@Mark,我可以直接运行任务。你的建议没有奏效。

标签: visual-studio-code vscode-debugger vscode-tasks


【解决方案1】:

变化:

"preLaunchTask": {
            "task": "audit_tunnel"
        }

收件人:

"preLaunchTask": "audit_tunnel"

【讨论】:

  • 以上对我来说至少改进了一些东西,现在它更具体了,说“找不到任务'/home/user/some/task.json'”,即使文件存在.
猜你喜欢
  • 2018-03-10
  • 2020-05-02
  • 1970-01-01
  • 1970-01-01
  • 2020-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多