当我在可视代码中单击“开始调试”时,我收到此错误。没有谷歌结果有效,我该如何解决?我正在尝试编译 C# 代码。
The preLaunchTask 'build' terminated with exit code 1.
我在我的 launch.json 文件和我的 VS 代码的另一个文件下面添加了一些代码,因为我不确定这是否有助于查看它们。
启动.json:
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
任务.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [ ],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
}
]
}
最佳答案
在您的 launch.json 文件中配置了一个 preLaunchTask
。它是在执行脚本之前运行的任务。该任务是来自您的 tasks.json 文件的“构建”。它失败了,正如它返回一个非零错误代码所表明的那样。您需要打开您的 tasks.json 配置文件,查看“构建”任务的内容,然后找出它失败的原因。
关于c# - VS 代码 : can't compile c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45901242/