puremourning / vimspector

vimspector - A multi-language debugging system for Vim
http://puremourning.github.io/vimspector-web
Apache License 2.0
4.1k stars 173 forks source link

Dotnet core debugging not working on Ubuntu (WSL 2) #211

Closed Nnoerregaard closed 4 years ago

Nnoerregaard commented 4 years ago

I'm having some trouble making dotnet core debugging work in Ubuntu (which is running in WSL 2) and hope someone in here can lead me in the right direction.

I've installed the csharp gadget and added a vimspector file containing the example configuration from the README (changed from netcoreapp2.2 to netcoreapp3.1, as I am using dotnet core 3.1) to my project. I've included the configuration below for convenience.

Unfortunately, the dll csharp.dll does not exist in the directory. I've tried the dll in that directory (/bin/Debug/netcoreapp3.1/) with name of my project which does indeed start debugging, but it only opens the Startup.cs file and the debugger is never attached to the C# process running my project so I can never hit any breakpoints. I've tried several other dll files in that folder too just in case, however, as expected, none of those work with the debugger (those are mostly project dependencies).

I've tried manually attaching to the process running my code which does indeed cause the debugger to break on my breakpoints, however, I don't get any visual indicate or any other information in the debugger views at all, everything is completely empty and it seems like the process hangs on the breakpoint indefinitely until I force kill it.

I'm not sure whether this is a vimspector bug or an issue with my setup of vimspector. Regardless, I'd love if somebody could help point me in the direction towards a solution.

Please let me know if you need any more information :)

{
  "configurations": {
    "launch - netcoredbg": {
      "adapter": "netcoredbg",
      "configuration": {
        "request": "launch",
        "program": "${workspaceRoot}/bin/Debug/netcoreapp3.1/csharp.dll",
        "args": [],
        "stopAtEntry": true
      }
    }
  }
}
puremourning commented 4 years ago

Please let me know if you need any more information :)

Yes, please can you complete the full issue template?

See CONTRIBUTING.md

puremourning commented 4 years ago

So, I know basically nothing about dotnetcore or any of this, but I just tried the sample in support/test/csharp locally on my Mac and it worked.

Does that work for you?

Nnoerregaard commented 4 years ago

I didn't realize there was a csharp sample, thank you for pointing me towards it. I did get the sample working, and I realized there were several misunderstandings on my part. Since I've previously used vimspector with node.js, I assumed I'd have to run my server outside of vimspector and connect to it through vimspector, however, after fiddling with the sample, I realized it works like vs code, where you start the project in debug mode, when you start the debugger. Unfortunately, I'm faced with an issue when trying to use the same vimspector configuration on our real project, namely that I don't know which port it's running on. I tried port 4711 which is apparently the default port of netcoredbg (https://github.com/Samsung/netcoredbg) but that wasn't. I also tried setting "port": --portNumber-- in the adapter configuration but without luck. Finally, I tried naively copying the profile settings used when running dotnet run (see below) into the adapter configuration, also without luck. Preferably, I'd like netcoredbg to use the settings below, so I can use swagger when developing on the API.

Is there any documentation available regarding how the netcoredbg gadget interfaces with netcoredbg and, in particular, what configuration options can be passed to it?

"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger/index.html",
"environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Local"
},
"applicationUrl": "https://localhost:44396;http://localhost:59899"

(PS I'd be happy to complete the full issue template if you still need it, however, I haven't done so yet, as I think this is more of a setup problem and perhaps a question of missing/hard to find documentation than it is an actual vimspector bug)

puremourning commented 4 years ago

This would be easier to discuss on Gitter.

There’s a lot in your post that I dont understand and none of it seems related to vimspector itself as far as I can tell.

I’m not in the business of documenting the debug adapters - that doesn’t scale (N of them, 1 of me).

I dunno if it helps but vimspector provides ${unusedLocalPort} to pick a free tcp port. The Vimspector reference guide explains variable replacements and suchlike.

Nnoerregaard commented 4 years ago

I'll take a look at Gitter and see, if I can find somebody knowns the netcoredbg gadget more in depth.