Omnisharp-vscode: Cannot debug a C# application

Created on 30 May 2017  路  15Comments  路  Source: OmniSharp/omnisharp-vscode

I am unable to debug a C# application, I am moving the issue to this repo as instructed by our friends at Microsoft

https://github.com/Microsoft/vscode/issues/27091#issuecomment-304612698

Debugger

All 15 comments

I'm not sure, but I don't know if a project with project.json works with netcore 1.1

Could you try to debug this simple app?

I get these errors upon build

build error

Okay, so then I click to show problems, then I get this (I will also report this on the other repo)

no problems

So I go through the first step again and instead press "Debug Anyway", and I get the same error in the previous issue, the debugger detaches for some reason.

Did you do dotnet restore before trying to debug?

I just ran those and it said
warn : The folder '/home/bkeys/Devel/hello-world-netcore/src/consoleApp' does not contain a project to restore.

I did it in the project root as well

warn : The folder '/home/bkeys/Devel/hello-world-netcore/' does not contain a project to restore.

Could you give me your dotnet --info?

[bkeys@localhost hello-world-netcore]$ dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003175)

Product Information:
 Version:            1.0.0-preview2-1-003175
 Commit SHA-1 hash:  bb053ed000

Runtime Environment:
 OS Name:     fedora
 OS Version:  25
 OS Platform: Linux
 RID:         fedora.25-x64

I'll try to reproduce this in my VM...

A few notes in case any of this is helpful:

  • Fedora 25 is not officially supported by .NET Core. I believe it will be officially supported for 2.0. As such, I don't know how successful you will be assuming you are trying to do .NET Core development (as opposed to Unity or some other C# scenario).
  • You can look at your tasks.json to see the exact command line being executed and try running that at a terminal.
  • If you are using .csproj projects, you should upgrade your build of the .NET SDK

Could you try to update your netcore?
As @gregg-miskelly said, Fedora 25 is not officially supported by .Net Core. I tried run in Fedora 24 and worked fine.

If you decide to upgrade your netcore version, you'll need to see these topics:

The dotnet Special Interest Group in Fedora does not have a more up to date binary to provide for Fedora for the time being, I will update it when a newer version is available. But shouldn't my old version still be able to run the consoleapp?
I have another hello world that can run, one of the issues appears to be when I run

dotnet run

I get this error

The current project is not valid because of the following errors:
/home/bkeys/Devel/hello-world-netcore/src/consoleApp(1,0): error DOTNET1017: Project file does not exist '/home/bkeys/Devel/hello-world-netcore/src/consoleApp/project.json'.

If I remember correctly .NET core uses project.json for linux and .csproj for windows; and this project uses .csproj

I have another project I created with dotnet that works just fine. But I am doing it from the command line when I run it.

No, project.json was the project file format for all projects from the start of the project through tooling v1.0 preview2. After tooling v1.0 preview2, the tooling switched to .csproj on all OSs. Project.json is deprecated now, and the version you have is the last release version that will ever be released that targets it.

Do you have a project.json in the path sited?

Technically you are running into a problem with the .NET CLI rather than this extension. But since you are using the deprecated tooling there isn't really a place for your bug.

@bhkeys it works because you have the 1.0 preview version installed.
In version 1.0 Microsoft uses a project.json for all project types on all platforms, but after version 1.1 they bring back the .csproj with a new and simpler structure.

You can see more in:

Alright, thank you guys for the information. I will keep up with the dotnet SIG and will check to see if this works on a newer version of .NET once it gets released

i have same issue, but with macos. The debugger not doing anything.

This is my configuratiin

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.2.104
 Commit:    73f036d4ac

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.104/

Host (useful for support):
  Version: 2.2.2
  Commit:  a4fd7b2c84

.NET Core SDKs installed:
  2.2.104 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
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/netcoreapp2.2/tutorial.dll",
            "args": [
                "start"
            ],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart",
            "launchBrowser": {
                "enabled": true,
                "args": "${auto-detect-url}",
                "windows": {
                    "command": "cmd.exe",
                    "args": "/C start ${auto-detect-url}"
                },
                "osx": {
                    "command": "open"
                },
                "linux": {
                    "command": "xdg-open"
                }
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ,]
}

task.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/tutorial.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

i got no error, debugger just running but, not doing anything.

@zeihanaulia if you would like help, please open a new issue, and include logs (instructions for enabling logging). Thanks!

Was this page helpful?
0 / 5 - 0 ratings