【发布时间】:2019-05-18 13:42:18
【问题描述】:
我在尝试在 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();
}
}
如果我运行程序,in 会执行并产生正确的输出。
在调试窗口中,我按下齿轮按钮编辑launch.jason 文件
这是它的样子:
{
"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}"
}
,]
}
当我点击绿色三角形按钮时,它没有命中断点。实际上,我认为我根本没有执行任何代码。 为了让这个应用程序进入调试模式,我有什么遗漏吗?
请帮忙!
【问题讨论】:
-
假设您已经尝试过干净/重新构建?
-
是的,没有任何区别 :( 实际上,代码中的这个过程开始是为了向自己保证,根本没有执行任何代码(当我按下绿色三角形按钮时)
-
我不得不问 - 但你在 Visual Studio 中处于调试模式吗?
-
我没用Visual Studio,我用的是Visual Studio Code,如果VS Code里有这样的设置,可惜没找到
标签: c# debugging visual-studio-code .net-core