Files
dotnet-runtime/docs/workflow/debugging/libraries/debugging-vscode.md
T
Mattias Karlsson 6ef9af19c2 ms-vscode.csharp to ms-dotnettools.csharp (#33354)
C# extension has changed its name from "ms-vscode.csharp" to "ms-dotnettools.csharp".
2020-03-09 14:00:22 +01:00

1.7 KiB

Debugging Libraries with Visual Studio Code

  • Install Visual Studio Code
  • Install the C# Extension
  • Open the folder containing the source you want to debug in VS Code - i.e., if you are debugging a test failure in System.Net.Sockets, open runtime/src/libraries/System.Net.Sockets
  • Open the debug window: ctrl-shift-D or click on the button on the left
  • Click the gear button at the top to create a launch configuration, select .NET Core from the selection dropdown
  • In the .NET Core Launch (console) configuration do the following
    • delete the preLaunchTask property
    • set program to the full path to dotnet in the artifacts/bin/testhost directory.
      • something like runtime/artifacts/bin/testhost/netcoreapp-{OS}-{Configuration}-{Architecture}, plus the full path to your corefx directory.
    • set cwd to the test bin directory.
      • using the System.Net.Sockets example, it should be something like runtime/artifacts/bin/System.Net.Sockets.Tests/netcoreapp-{OS}-{Configuration}-{Architecture}, plus the full path to your corefx directory.
    • set args to the command line arguments to pass to the test
      • something like: [ "exec", "--runtimeconfig", "{TestProjectName}.runtimeconfig.json", "xunit.console.dll", "{TestProjectName}.dll", "-notrait", ... ], where TestProjectName would be System.Net.Sockets.Tests
      • to run a specific test, you can append something like: [ "method", "System.Net.Sockets.Tests.{ClassName}.{TestMethodName}", ...]
  • Set a breakpoint and launch the debugger, inspecting variables and call stacks will now work