tasks.json 存在但 'No task defined'

tasks.json exists but 'No task defined'

我在 VSCode 中打开了一个 tasks.json。当我尝试 'Run Task' 我得到 'No task to be run. Configure Tasks'.

尝试配置任务时我得到 'Open tasks.json'。但是 tasks.json 已经在 VSCode 中打开了。关闭 tasks.json 并重新打开它会得到相同的结果。

感谢帮助。 tasks.json如下所示。

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
   "label": "GnuCOBOL - Compile (single file)",
   "type": "shell",
   "options": {
    "env": {
        "PATH":"\gnucobol3\bin",
        "COB_CONFIG_DIR": "c:\gnucobol3\config",
        "COB_COPY_DIR": "c:\gnucobol3\copy",
        "COB_INCLUDE_PATH": "c:\gnucobol3\include",
        "COB_LIB_PATH": "c:\gnucobol3\lib",
       },
    "command": "cobc",
    "args": [
      "-x",
      "-std=mf",
      "-t${fileBasenameNoExtension}.LST",
      "${file}"
      ]
    },
} 

您的 tasks.json 文件似乎已更改。它应该是这样的形式:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",

  // "global" options can go here

  "options": {
    "env": {
        "APP_NAME": "Nice"
    }
  },

  // you are missing the tasks array

  "tasks": [

    {                             // task 1
            "label": "Task A",
            "type": "shell",
            "command": "echo A2",
            "problemMatcher": [],
            "presentation": {
                "group": "groupA"
            }
            // or task-specific options can go here
        },
        {                         //  task 2
            "label": "Task B",
            "type": "shell",
            "command": "echo B",
            "problemMatcher": [],
            "presentation": {
                "group": "groupA"
            }
        }
   ]
}

所以用你的代码:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "options": {
    "env": {
      "PATH":"\gnucobol3\bin",
      "COB_CONFIG_DIR": "c:\gnucobol3\config",
      "COB_COPY_DIR": "c:\gnucobol3\copy",
      "COB_INCLUDE_PATH": "c:\gnucobol3\include",
      "COB_LIB_PATH": "c:\gnucobol3\lib",
     }
    },

    "tasks": [
       {
          "label": "GnuCOBOL - Compile (single file)",
          "type": "shell",
          "command": "cobc",
          "args": [
            "-x",
            "-std=mf",
            "-t${fileBasenameNoExtension}.LST",
            "${file}"
          ]
        }
      ]
    }
  }
}

不确定如何回复 - 我的回复太大而无法发表评论。

马克:我已经修改了 tasks.json 但仍然出现相同的错误:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",

    {
      "label": "GnuCOBOL - Compile (single file)",
      "type": "shell",
      "options": {
        "env": {
          "PATH":"\gnucobol3\bin",
          "COB_CONFIG_DIR": "c:\gnucobol3\config",
          "COB_COPY_DIR": "c:\gnucobol3\copy",
          "COB_INCLUDE_PATH": "c:\gnucobol3\include",
          "COB_LIB_PATH": "c:\gnucobol3\lib",
        },
        "tasks": [
         {"command": "cobc",
          "args": [
           "-x",
           "-std=mf",
           "-t${fileBasenameNoExtension}.LST",
           "${file}"
          ]
        }
      ]
    }
  }
}

马克:你的模组现在 运行 但有错误:

> Executing task: cobc -x -std=mf -ttasks.LST c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json <

c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:2: error: invalid indicator 'e' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:3: error: invalid indicator 'o' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:4: error: invalid indicator 's' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:5: error: invalid indicator 'i' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:6: error: invalid indicator 'n' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:7: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:8: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:9: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:10: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:11: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:14: error: invalid indicator 'k' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:16: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:17: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:18: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:19: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:24: error: invalid indicator ']' at column 7