错误:preLaunchTask 'build' 以退出代码 1 终止

Mic*_*cil 5 c# macos visual-studio-code

Visual Studio 在 OSX 上调试 c# 脚本,显示错误:preLaunchTask 'build' 以退出代码 1 终止。

这是 launch.json 文件的副本:

{
    "version": "0.2.0",
    "configurations": [{
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/hwapp.dll",
            "args": [],
            "cwd": "${workspaceRoot}",
            "stopAtEntry": false,
            "externalConsole": false
        },
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/hwapp.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}"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是 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"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我如何解决这个问题???PLS

Jus*_*tin 0

如果您使用 MacPorts,那么这可能是您的问题(对我来说)

我在我的.zshrc.profile等中找到了这个链接到 OpenSSL 的 MacPorts 版本:

export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:~/lib:/usr/local/lib:/lib:/usr/lib
Run Code Online (Sandbox Code Playgroud)

.NET Core 从这里开始工作。

VSCode 或Rider都不会调试(我收到了您收到的错误)

我的问题是OmniSharp的问题,这里是引发错误的文件的链接。Debug: Download .NET Core Debugger您可以通过在 VSCode 的命令托盘中输入来验证安装是否失败:

为了解决这个问题,我为 OpenSSL 创建了 2 个符号链接(不是超级优雅,但是......):(
您可能不再需要使用这些符号链接进行上述导出)

% sudo ln -s /opt/local/lib/libcrypto.1.0.0.dylib /usr/local/lib/
% sudo ln -s /opt/local/lib/libssl.1.0.0.dylib /usr/local/lib/
Run Code Online (Sandbox Code Playgroud)

然后我重新安装了VSCode的C#插件,并Debug: Download .NET Core Debugger在命令托盘中重新执行。我现在可以在 VSCode 和 Rider 中进行调试。


*如果这对您不起作用,您可能会从上述 VSCode 命令中获得一些有用的输出/信息。