I am trying to debug my c# app with neovim DAP. Here is my configs:
local dap = require('dap')
dap.adapters.coreclr = {
type = 'executable',
command = '/home/asd/netcoredbg/netcoredbg',
args = { '--interpreter=vscode' },
}
dap.configurations.cs = {
{
type = "coreclr",
name = "launch - netcoredbg",
request = "launch",
program = function()
-- return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file')
return vim.fn.input('Path to dll: ')
end
},
}
When i run DAP with my dll, I get these errors:
I tried to use netcoredbg
cli tool separately, like this: ~/netcoredbg/netcoredbg --interpreter=cli -- dotnet run ./bin/Debug/net7.0/WebApi.dll environment=DevelopmentLocalhost
and everything works fine.
So i pretty sure that my dap configs are wrong. Thanks for help!
UPD: I answered my actual question below. BUT! The last question remains: is there a way to setup dap
to just use launch.json
generated by VsCode
and how to do that?
So.. I get it working with configs like this:
...
justMyCode = false,
stopAtEntry = false,
program = function()
-- todo: request input from ui
return "/path/to/your.dll"
end,
env = {
ASPNETCORE_ENVIRONMENT = function()
-- todo: request input from ui
return "Development"
end,
ASPNETCORE_URLS = function()
-- todo: request input from ui
return "http://localhost:5050"
end,
},
cwd = function()
-- todo: request input from ui
return vim.fn.getcwd()
end,
...
So key thing here is that we pass envs using env
property of cs
config object. Just like other fields it can be exact value, or can be a function where we can e.g. get input from ui and then use as a value for env variable:
ASPNETCORE_ENVIRONMENT = "Development"
or
ASPNETCORE_ENVIRONMENT = function()
return vim.fn.input("ASPNETCORE_ENVIRONMENT: ", "Development")
end,
Also, its important to set cwd
, e.g. because appsettings.json
will be searched there
cwd = function()
return vim.fn.input("Workspace folder: ", vim.fn.getcwd() .. "/", "file")
end,