Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to debug in VS Code using Dev Containers? #281

Closed
andwak opened this issue Apr 10, 2022 · 2 comments
Closed

Is it possible to debug in VS Code using Dev Containers? #281

andwak opened this issue Apr 10, 2022 · 2 comments

Comments

@andwak
Copy link

andwak commented Apr 10, 2022

Hi,

I have setup a project and the Bazel build works well. Bazel run also works.
I can create a debug build with the option '-c dbg' and attach to the executing process.

However, whenever I try to debug code I have written, VS code does not find the .cs file.
My assumption is, that I need to tell the compiler where the source code can be found.

I have had no success with 'sourceFileMap' in the launch.json file.
Maybe we need to specific the 'GenerateFullPaths' property for the compiler?

Did anybody manage to get this working?

Thanks for any pointers.

@andwak andwak changed the title Is it possible to debug is VS Code using Dev Containers? Is it possible to debug in VS Code using Dev Containers? Apr 11, 2022
@andwak
Copy link
Author

andwak commented Apr 22, 2022

I carried out further investigation.

Bazel dotnet rules create a .param file containing the parameters for the csc.exe compilation call.
I no longer suspect this is related to /fullpaths (GenerateFullPaths) configurations (I added this property in a test branch).

When VS Code prompts to create the "file that is not found" and I manually replace this file with the source code file content, I can then debug. Obviously this is not a solution, just part of my analysis.

I then started to investigate the .pdb files that are created. I saw that the pdb contains a section "document" and this points to a folder where the assembly is executed. For example:

/root/.cache/bazel/_bazel_root/"xxx"/sandbox/processwrapper-sandbox/1237/execroot/main/"TargetFolder"/"MyCSharpFile".cs

The source code files do not exist in this location.

This appears to be handled by the csc.exe compiler.
I will try and analyse if this can be configured.

@andwak
Copy link
Author

andwak commented Apr 22, 2022

I managed to debug using the flag "--sandbox_debug"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant