VS代码:无法编译c#

时间:2017-08-27 02:36:23

标签: c# .net visual-studio-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 :(得分:0)

您的launch.json文件中配置了preLaunchTask。这是在执行脚本之前运行的任务。您的tasks.json文件中的任务是“构建”。它失败了,正如它返回非零错误代码所表明的那样。你需要打开你的tasks.json配置文件,看看&#39; build&#39;任务需要,然后找出它失败的原因。