c# - VS 代码 : can't compile c#

标签 c# .net visual-studio-code

当我在可视代码中单击“开始调试”时,我收到此错误。没有谷歌结果有效,我该如何解决?我正在尝试编译 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/

相关文章:

c++ - 使用 MsBuild 构建 Visual Studio Code

multithreading - 更改 Julia 的 Jupyter Notebooks 的 VS Code 的 settings.json 中的线程

c# - 无限while循环问题

c# - 如何取消选择组合框的文本

c# - 我可以将构造函数参数传递给 Unity 的 Resolve() 方法吗?

c# - 如何使用标准 MVC Core 依赖注入(inject)解决未注册的类型

c# - 数据库层缓存、触发器和失效

c# - 自启动和故障异常

c# - WrapPanel 不在 WPF ListView 中换行

visual-studio-code - Visual Studio代码通知询问我是否要排除Java项目设置文件