-
-
Notifications
You must be signed in to change notification settings - Fork 41
DAP support C#
Compiling with the options Build and run dotnet
or Build dotnet
will automatically generate a .exe
in debug mode, and the necessary runtimeconfig.json
file. So if your C# project has a .csproj
file, this would be the easy way. The only thing left to do if opening DAP
and selecting the .exe
(as described below).
Create a .solution
file in your working directory. Then pass the -debug
parameter to the compiler like this
[HELLO WORLD]
entry_point="/path/to/my/entry_point_file/main.c"
output="/path/where/the/program/will/be/written/hello_world"
parameters="-debug"
After compiling your program you will see the file <your_exe_name>.pdb
beside your executable. This proves you are compiling in debug mode.
Please note that this section has nothing to do with compiler.nvim. I'm documenting this to make your life easier. To debug C# with DAP you have to:
- Install the package
netcoredbg
in your system - Setup
DAP
for C# - Create the file
<your_exe_name>.runtimeconfig.json
in your executable directory. For example if your program isProgram.exe
, name itProgram.runtimeconfig.json
.
{
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true,
"System.GC.Concurrent": true,
"System.Threading.ThreadPool.MinThreads": 1,
"System.Threading.ThreadPool.MaxThreads": 1
},
"tfm": "netcoreapp2.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "7.0.9"
},
"applyPatches": true,
"rollForwardOnNoCandidateFx": 1
}
}
But instead of version 7.0.9
, use the Microsoft.NETCore.App
version you have installed in your system. On Arch Linux you can check it on the directory /usr/share/dotnet/shared/Microsoft.NETCore.App/
to discover it.
Compile your program, add a break point to your code, and then run DAP
. You will see something like this.
Congratulations, now you can compile and debug C#.
If you find any issue while configuring DAP, run :DapSetLogLevel trace
and :DapShowLog
to find the reason.