5

I followed the default steps to

  • install .NET Core, (linux-package-manager-ubuntu-1604)
  • create and open (ASP.NET core Empty) project in VSCode, (cd ~/projects && dotnet new web -o my-api && cd my-api && code .)
  • add vscode tasks.json and launch.json(C# Extension), (ms-dotnettools.csharp)
  • add breakpoints(in VSCode),
  • and start debugging (press F5 in VSCode).

But this doesn't start the webserver and doesn't stop at breakpoints... It does built the project, as I can see files generated in bin/Debug/netcoreapp3.1/

Running dotnet run inside projects root, builds(restores) and runs the webserver, and I can browse to https://localhost:5001 and http://localhost:5000. But can't debug...

This is the created vscode files

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 (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/my-api.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}
tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/my-api.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/my-api.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "watch",
            "command": "dotnet",
            "type": "process",
            "args": [
                "watch",
                "run",
                "${workspaceFolder}/my-api.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

F5 first shows Terminal-tab, then switches to the Debug Console-tab in VSCode

Terminal-tab
> Executing task: dotnet build /home/user/projects/my-api/my-api.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <

Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 76,69 ms for /home/user/projects/my-api/my-api.csproj.
  my-api -> /home/user/projects/my-api/bin/Debug/netcoreapp3.1/my-api.dll

Terminal will be reused by tasks, press any key to close it.
Debug Console
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
4
  • I have the same issue under Regolith Linux 1.5 (Ubuntu 20.04 based), it happened after a fresh install, it use to work, I'll keep you updated if I find a solution Commented Jan 9, 2021 at 0:30
  • What version of libcu did you install when installing dotnet-sdk? Commented Jan 9, 2021 at 0:54
  • were you able to make it work? Commented Sep 14, 2021 at 18:07
  • 1
    No, and I removed .Net as I switched to something else. Once I reinstall .Net on my Linux machine, I will take notes of my install/use progress Commented Sep 23, 2021 at 9:21

2 Answers 2

2

It seems to be an issue from the installation of VS Code itself, I simply reinstalled VS Code and the issue went away.

sudo snap remove code
sudo snap install code --classic

Although this unsatisfying solution, I have a supposition on why this could have happened.

I installed my modules using the CLI instead of using the GUI. I say that, because I've seen installation log while I was running my web application. I suppose that the installation of the debugger might not have been finished by the time I was running the application. That might have caused a package corruption. But, just uninstalling the extension didn't fix the issue, so I'm not sure that's what happened.

code --install-extension ms-dotnettools.csharp

If reinstalling doesn't work for you, let me know, and also try to change your launch.json, replace openExternally with debugWithChrome. I changed the setting at the same time I reinstalled VS Code.

Sign up to request clarification or add additional context in comments.

Comments

-1

I had the same issue.

First restart the system and see if it gets fixed. Otherwise, try MathieuAuclair's solution then restart the system.

This worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.