我使用的是manjaro linux,Visual Studio Code无法调试任何语言的任何代码,总是给我"找不到任务xxx"的错误。xxx部分因每种语言、我尝试的每一个程序和我选择的每一种配置而异。我该怎么办?
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": "cpp - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "cpp build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
},
{
"type": "shell",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
对于Ubuntu Linux 20.04 LTS,preLaunchTask对我来说起作用的是同时使用本地tasks.json和launch.json(与~/.config/Code/User/settings.json中的全局启动配置相反(
因此,一个基本的本地文件夹结构(预构建(可能是:
.vscode/launch.json
.vscode/tasks.json
src/index.js
package.json
我的launch.json包含:
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "preLaunchTask-build",
"program": "${file}",
"preLaunchTask": "build",
"skipFiles": [
"<node_internals>/**", "node_modules",
]
},
]
}
我的tasks.json包含:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "echo hello yes working!",
"problemMatcher": [],
"label": "build"
},
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": ["$tsc"],
"group": "build",
"label": "tsc: build"
},
]
}
用法:在index.js中,只需点击F5并设置断点。
我还包括一个";tsc:build;版本,以查看另一个构建配置示例(本例中用index.ts替换index.js(