如何为 C# dotnet 配置 .json 选项以在 VS CODE 中的内部终端中调试控制台应用程序

问题描述 投票:0回答:1

实际上,我现在遇到的问题与 ReadKey InvalidOperationException 应用程序没有控制台完全相同。

但是该问题中提供的所有解决方案对我来说都不起作用。它不起作用的原因是我既不能添加

"console": "integratedTerminal"
也不能添加
"internalConsole":true
(这些选项也可以在VS Code官方页面中找到)但是我搜索了很多但没有关于这些的信息。

VS Code 警告“不允许使用属性控制台/内部控制台。”

我当前的.json配置文件如下:

    {
    "version": "0.2.0",
    "configurations": [
        {
        "name": "C#: Events Example",
        "type": "dotnet",
        "request": "launch",
        "projectPath": "${workspaceFolder}/Event/Event.csproj",
        "launchConfigurationId": "TargetFramework=;Microsoft.NETCore.App"
        }
    ]
    }

总结一下,如何使用终端在 linux 中的 VS Code 中调试 C# Dotnet 应用程序?

c# .net visual-studio-code console-application vscode-debugger
1个回答
0
投票

您可以使用launch.json文件的console属性并将其设置为externalTerminal。此属性指定用于启动或附加程序的控制台类型。通过将其设置为 externalTerminal,您可以使用您选择的终端来运行和调试 C# Dotnet 应用程序。例如,您可以使用以下代码:

{
"version": "0.2.0",
"configurations": [
        {
        "name": "C#: Events Example",
        "type": "dotnet",
        "request": "launch",
        "projectPath": "${workspaceFolder}/Event/Event.csproj",
        "launchConfigurationId": "TargetFramework=;Microsoft.NETCore.App",
        "console": "externalTerminal" // Add this line to use external terminal
        }
]
}
© www.soinside.com 2019 - 2024. All rights reserved.