我正在使用VS Code在C#上的小型控制台应用程序上工作,但无法使用调试工具(即使PC上安装了SDK和C#扩展程序)。
当我在终端上运行dotnet run
时,它可以工作,但是当我尝试调试部分代码时,我得到了:
我认为launch.json和task.json文件存在一些问题,但我不知道该怎么办。
我也看过https://74th.github.io/vscode-debug-specs/csharp/,但问题仍然存在。
答案 0 :(得分:0)
我要感谢user14492的建议,现在我在项目中使用Visual Studio(而不是VS Code),并且调试工具运行良好。
这个Liam看起来很客气,如果您发现令人讨厌的gif只是忽略而已,那就不要混蛋。
答案 1 :(得分:-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