【问题标题】:Problems with Visual Studio Code C# DebuggingVisual Studio Code C# 调试问题
【发布时间】:2020-02-04 15:30:34
【问题描述】:

我正在使用 VS Code 在 C# 上处理一个小型控制台应用程序,但我无法使用调试工具(即使我的 PC 上安装了 SDK 和 C# 扩展)。

当我在终端上运行dotnet run 时它可以工作,但是当我尝试调试部分代码时,我得到:

我认为这是 launch.json 和 tasks.json 文件的问题,但我不知道该怎么办。

我也看过https://74th.github.io/vscode-debug-specs/csharp/,但问题依然存在。

【问题讨论】:

标签: c# debugging visual-studio-code


【解决方案1】:

我要感谢 user14492 的建议,现在我在我的项目中使用 Visual Studio(不是 VS Code)并且调试工具运行良好。

这个Liam 看起来很不友好,如果你觉得这个 gif 很烦人,请忽略,不要混蛋。

【讨论】:

    【解决方案2】:

    tasks.json

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build",
                "command": "dotnet",
                "type": "process",
                "args": [
                    "build",
                    "${workspaceFolder}/ConsoleApplicationDemo.csproj",
                    "/property:GenerateFullPaths=true",
                    "/consoleloggerparameters:NoSummary"
                ],
                "problemMatcher": "$msCompile"
            },
            {
                "label": "publish",
                "command": "dotnet",
                "type": "process",
                "args": [
                    "publish",
                    "${workspaceFolder}/ConsoleApplicationDemo.csproj",
                    "/property:GenerateFullPaths=true",
                    "/consoleloggerparameters:NoSummary"
                ],
                "problemMatcher": "$msCompile"
            },
            {
                "label": "watch",
                "command": "dotnet",
                "type": "process",
                "args": [
                    "watch",
                    "run",
                    "${workspaceFolder}/ConsoleApplicationDemo.csproj",
                    "/property:GenerateFullPaths=true",
                    "/consoleloggerparameters:NoSummary"
                ],
                "problemMatcher": "$msCompile"
            }
        ]
    }
    

    launch.json

    {
       // 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 (console)",
                "type": "coreclr",
                "request": "launch",
                "preLaunchTask": "build",
                // If you have changed target frameworks, make sure to update the program path.
                "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/ConsoleApplicationDemo.dll",
                "args": [],
                "cwd": "${workspaceFolder}",
                // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
                "console": "internalConsole",
                "stopAtEntry": false
            },
            {
                "name": ".NET Core Attach",
                "type": "coreclr",
                "request": "attach",
                "processId": "${command:pickProcess}"
            }
        ]
    }
    

    参考以下网址:https://medium.com/edgefund/c-development-with-visual-studio-code-b860cc71a5ec

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 1970-01-01
      • 2019-08-19
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多