Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code .NET Core debugger not hitting a breakpoint

I have a problem trying to debug applications written in .NET Core in Visual Studio Code. Here is the setup: I'm using a virtual machine running Debian 9 (with the default GUI). I've installed .Net Core SDK 2.1, and Visual Studio Code 1.30.0. Installed the extensions for C# 1.17.1. I've created simple project:

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();
    }
}

If I run the program, in executes, and produces the correct output. In the debug window I pressed the gear button to edit the launch.jason fileDebug window

Here it is what it looks like:

{
 "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}"
    }
 ,]
}

I've put a breakpoint in the project: Breakpoint

and when I hit the green triangle button, the breakpoint it not hit. Actually I think that non of the code i executed at all. Is there something I'm missing to get this app it debugging mode?

Please help!

like image 493
Julian Avatar asked Jul 12 '26 16:07

Julian


2 Answers

I was having the same issue on a different setup. Running windows 10 using VSCode and dotnet sdk 2.2.

I found a few answers browsing through gissues Here.

And This one I think fixed my problem

I also noticed to make sure I was selecting the correct "c:/projectdir/bin/debug/projectname.dll" when asked to attach the debugger to a process.

After that VSCode successfully hit my breakpoint.

I hope this helps.

like image 194
Tribalnecktie Avatar answered Jul 15 '26 07:07

Tribalnecktie


1) In terminal go to your project and write

dotnet restore
dotnet clean
dotnet build

2) Check paths of "program" and "cwd" in your configurations (launch.json).

like image 42
Maciej Pulikowski Avatar answered Jul 15 '26 05:07

Maciej Pulikowski