Skip to content

cs compiler

Zeioth edited this page Jul 31, 2023 · 19 revisions

How to compile your C# program to debug it with DAP

After compiling your C# project, you can use DAP to debug it. To do so, create a .profile file in your working directory. Then pass the -debug parameter to the compier 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"

If it has worked, after compiling your program you will se the file Program.dpb beside your executable.

How to setup DAP to debug with C#

Please note that this section has nothing to do with compiler.nvim. I'm documenting the process to make your life easier. To debug C# with DAP you need to

  • Install the package netcoredbg in your system
  • Setup DAP for C#
  • Create the next file in the directory of your executable
{
    "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 you can check it on the directory/usr/share/dotnet/shared/Microsoft.NETCore.App/)

How to check if everything works

Compile your program, add a breakpoint to your code, and then run DAP. You will see something like this

screenshot_2023-08-01_00-12-29_277199356

Congratulations, now you can compile and debug C#.

Clone this wiki locally