Search code examples
c#debuggingvisual-studio-codenugetpdb-files

debug nuget in Visual Studio Code


  • I have a project A that produces a nuget N.
  • I have a project B that uses N.
  • I have a debug configuration for B, i.e. I can step through the code of B.

I also want to step through the code of A during debugging B, but it does not work just like this.

Since I build N from A myself, I can generate a symbols package and/or a pdb file, so I think I do have all that is needed. I just don't know how I can connect these pieces to allow me debugging the A-code from within the B-debugging-session.


Solution

  • Setting <DebugType>portable</DebugType> in my csproj files (both for A and B) did the trick.

    I did not even need to copy the pdb file from A anywhere; it just worked on its own.

    Might be that this is just due to my current setup: I have a nuget.config for project B where the path to project A is specified, because the nuget N is built there. And since it is project A's folder, its pdb is in there as well (in bin/Debug/frameworkVersion). Might be that VScode just checks the folder from where the nuget was retrieved, as well as all subfolders.

    Anyway, if that won't work for a different setup, it seems it is enough to just copy the pdb of the code I want to debug (so, of project A's code) into the output folder of the project I'm currently debugging (project B). This can be achieved automatically by adding the pdb to the nuget as well as a corresponding target to copy the pdb to the output directory.

    Then, if just my code is disabled, the pdb file will automatically be loaded.