bazel-contrib / bazel-contrib/rules_dotnet
Debugging in VS Code don't work with generated pdb-files
- Dominant language
- Starlark
- Stars
- 209
- Forks
- 98
- Avg merge
- 3h 59m
- Merged PRs (30d)
- 14
Description
I don't get debugging in VS code when I build with Bazel. Does anyone have succeeded with this? Here is what I've tried with my executable Foo. If you have something working, it would be very appreciated if you could share how this is done.
I've created a task.js-file and a launch.js-file. I build with the specified command. The flag --compilation_mode=dbg generates .pdb-files as expected. The preLaunchTask in VS Code builds it and the program is executed. I've tried to both launch the generated Foo.exe_0.exe and the dotent.exe with Foo.exe as an argument. It starts and runs well. But it does not stop at the breakpoints.
I have tried to play around with sourceFileMap, but with no success. Is it anything wrong with my set up or is it not (yet) possible? The workaround is to build with .csproj-files with Visual Studio, then it is working, but then there is no point with Bazel really. Anyone who have any hints how to make it work?
**task.js-file**:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "./../bazelw build ///Foo/... --config=msvc64 --config=remotecache_download --compilation_mode=dbg,
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean",
"command": "./../bazelw clean --expunge",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},
{
"label": "run tests",
"command": "./../bazelw test ///Foo/... --config=msvc64 --config=remotecache_download --test_output=all",
"dependsOn": "build",
"type": "shell",
"group": "test",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
}
]
}
**launch.js-file**:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attempt 1",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "PathOrRelativePathToParentRepo\\bazel-bin\\Foo\\Foo.exe\\Foo.exe_0.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
},
{
"name": "Attempt 2",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "PathOrRelativePathToParentRepo\\bazel-bin\\Foo\\Foo.exe\\dotnet.exe",
"args": [
"PathOrRelativePathToParentRepo\\bazel-bin\\Foo\\Foo.exe\\Foo.exe"
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceFileMap":
{
"C:\\build\\4hga4mmj\\execroot\\RepoName": "PathOrRelativePathToParentRepo"
}
},
{
"name": "Built with Visual Studio - works fine - stops at breakpoints",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "PathOrRelativePathToParentRepo\\Foo\\bin\\Debug\\netcoreapp3.1\\Foo.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
Contributor guide
Research direction
Start with the supplied task.js-file and launch.js-file, then compare the two Bazel launch configurations with the working Visual Studio configuration. Verify how the generated Foo.exe_0.exe, dotnet.exe, Foo.exe, PDB files, and sourceFileMap relate, and consider the issue done when Bazel-built code stops at VS Code breakpoints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, vscode
- Domain
- build-system, developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100