关于VScode报错“终端将被任务重用,按任意键关闭”的解决方案
这其实不是一种报错,有这个提示的原因是本地端口是被共享的,所以必须关闭一个进程才能执行另一个,只需要对
tasks.json
文件做一些修改即可。
报错时候
此时的tasks.json
为:
{
"version": "2.0.0",
"command": "g++",
"args": ["-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}.exe"], // 编译命令参数
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared", //这里shared表示共享,改成new之后每个进程创建新的端口
"showReuseMessage": true,
"clear": false
}
}
此时编译:
![](https://raw.githubusercontent.com/talesov/picbed/master/img/20200221214207.png)
解决方案
如果tasks.json
中没有presentation
,就自己写一个,然后把"panel"="shared"
改成:
"panel"="new"
问题解决:
![](https://raw.githubusercontent.com/talesov/picbed/master/img/20200221214522.png)