【问题标题】:Debugging ASP.NET Web App on VS Code Linux doesnt work在 VS Code Linux 上调试 ASP.NET Web 应用程序不起作用
【发布时间】:2018-10-16 19:45:10
【问题描述】:

我正在使用本教程测试 ASP.NET Core:https://www.blinkingcaret.com/2018/03/20/net-core-linux/

从终端构建和运行时,CLI 和 Web 应用程序都可以正常工作:

网络应用:

dotnet run
Using launch settings from /home/peter/Documents/dotnet_linux/Reminders.Web/Properties/launchSettings.json...
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
    User profile is available. Using '/home/peter/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Development
Content root path: /home/peter/Documents/dotnet_linux/Reminders.Web
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

但是,从 VS Code 1.28.1 开始,我只能运行 CLI 应用程序。当我为网络应用添加配置时:

{
    // Use IntelliSense to find out which attributes exist for C# debugging
    // Use hover for the description of the existing attributes
    // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/Reminders.Web/bin/Debug/netcoreapp2.1/Reminders.Web.dll>",
            "args": [],
            "cwd": "${workspaceFolder}/Reminders.Web/bin/Debug",
            "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": "${workspaceFolder}/Views"
            }
        },
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/Reminders.Cli/bin/Debug/netcoreapp2.1/Reminders.Cli.dll",
            "args": [],
            "cwd": "${workspaceFolder}/Reminders.Cli",
            // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
            "console": "internalConsole",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        },
    ]
}

我得到了错误

这个DLL确实存在。

我在这里查看了 launch.json 的所有配置选项:https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md,但没有找到任何东西

【问题讨论】:

  • 您的文件系统中的文件末尾真的有那个额外的尖括号吗?不知何故,我怀疑它,看起来你在你的配置文件中偷偷输入了一个错字。
  • 我不这么认为,但你指的是哪个括号? VS Code 没有抱怨,因为我可以在 VSCode 中运行 CLI 项目,所以我认为它没有什么大问题。
  • 查看错误信息。您看到引号中的路径吗?你看到它的末端有一个尖括号吗? > 这是路径的一部分,您的文件系统上不太可能有一个名为 Reminders.Web.dll> 的文件。
  • 100% 正确,先生!该死的,我怎么能错过……而且没有来自 VSCode 的任何警告……现在运行完美!输入答案,以便我接受。
  • VS Code 并不神奇。它无法检查所有内容。当它检查并告诉你文件不存在时......好吧,你可以从那里处理!

标签: asp.net visual-studio-code .net-core


【解决方案1】:

你有一个额外的尖括号。

改变

"program": "${workspaceFolder}/Reminders.Web/bin/Debug/netcoreapp2.1/Reminders.Web.dll>",

 "program": "${workspaceFolder}/Reminders.Web/bin/Debug/netcoreapp2.1/Reminders.Web.dll",

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 2019-06-25
    • 1970-01-01
    • 1970-01-01
    • 2020-06-02
    • 2018-08-16
    相关资源
    最近更新 更多