我在尝试在Visual Studio Code中调试使用.NET Core编写的应用程序时遇到了问题。以下是设置:
我正在使用运行Debian 9(带有默认GUI)的虚拟机。我已安装.Net Core SDK 2.1和Visual Studio Code 1.30.0。安装了C# 1.17.1扩展。我已创建了一个简单的项目:
class MyProgram
{
static void Main(string[] args)
{
Console.WriteLine("Hello You Angel!");
ProcessStartInfo startInfo = new ProcessStartInfo() { FileName = "/bin/bash", Arguments = "-c nautilus /home/", };
Process proc = new Process() { StartInfo = startInfo, };
proc.Start();
}
}
如果我运行程序,它会执行并产生正确的输出。 在调试窗口中,我按下了齿轮按钮来编辑
launch.jason
文件![Debug window](https://istack.dev59.com/rkL6U.webp)
{
"version": "0.2.1",
"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}/HelloWorld/bin/Debug/netcoreapp2.1/HelloWorld.dll",
"args": [],
"cwd": "${workspaceFolder}/HelloWorld",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "integratedTerminal",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"externalConsole": false,
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
我在项目中设置了断点:
![Breakpoint](https://istack.dev59.com/dN3up.webp)