VS Code: 无法编译C#

3
当我在Visual Code中点击“开始调试”时,会收到此错误消息。没有谷歌搜索结果可以解决它,那该怎么办呢?我正在尝试编译C#代码。
The preLaunchTask 'build' terminated with exit code 1.

我可以帮助您进行翻译。以下是我的launch.json文件和VS代码的另一个文件的一些代码。我不确定是否有帮助,因此将它们添加在下面。 launch.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}"
        }
    ]
}

tasks.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"
        }
    ]
}
1个回答

0

您的 launch.json 文件中配置了一个 preLaunchTask。它是在脚本执行之前运行的任务,而该任务是来自 tasks.json 文件的 'build' 任务。由于其返回了非零错误代码,因此该任务失败了。您需要打开 tasks.json 配置文件,查看 'build' 任务的内容,然后找出为什么它失败了。


我已经更新了我的问题,附上了tasks.json和launch.json,请您看一下好吗?谢谢。 - user8516396

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接