Skip to content

VS Test Explorer never completes when debugging test in WSL2 #7043

@bart-vmware

Description

@bart-vmware

Describe the bug

When debugging a test in Visual Studio 2026 Test Explorer on WSL2 (Ubuntu), my breakpoint is hit. Then, running the test to completion or stopping the debugger, Test Explorer shows the test is still running and debugging again is impossible. I'm using xUnit v3 with MTP v2.

Steps To Reproduce

  • Download the attached repro project (see below)
  • Download Ubuntu v22.04 from the Windows Store and open it to create an Ubuntu user account
  • Install .NET 10 in Ubuntu WSL2, as described at https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-install?tabs=dotnet10&pivots=os-linux-ubuntu-2204#ubuntu-2204:
    • sudo add-apt-repository ppa:dotnet/backports
    • sudo apt-get update && sudo apt-get install -y dotnet-sdk-10.0
    • Configure your Ubuntu user account to run sudo without password, as described at https://askubuntu.com/questions/147241/execute-sudo-without-password, so that VS can install the debugging tools without hanging on a hidden console that prompts for a password
  • Extract the attached zip file and open the solution in VS
  • Open Test Explorer and switch to Ubuntu-22.04 (defined in testenvironments.json)
  • Add a breakpoint on the unit test
  • In Test Explorer, click Run all tests (succeeds)
  • Expand the tree, right-click on the test and select Debug
  • The breakpoint gets hit, but Test Explorer shows an error
    Image
  • Press F5 to run the test to completion; the debugger detaches
  • Test Explorer debugging is no longer possible, as it believes the test is still running
    Image

Expected behavior

Being able to debug a test multiple times.

Actual behavior

It's only possible to debug a test once. A VS restart is required to debug again.

DebuggerHangsInWSL2.zip

The Tests output from the VS Output window contains the following:

System.Runtime.InteropServices.COMException (0x89710080): Unable to attach. The process has been terminated.

Refresh the process list before attempting another attach.
   at Microsoft.VisualStudio.Shell.Interop.IVsDebuggerLaunchAsync.LaunchDebugTargetsAsync(UInt32 debugTargetCount, VsDebugTargetInfo4[] debugTargetArray, IVsDebuggerLaunchCompletionCallback completionCallback)
   at Microsoft.VisualStudio.TestWindow.ShellServices.DebuggerService.<>c__DisplayClass25_0.<<LaunchDebuggerAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__14`1.MoveNext()
Connecting to client host '127.0.0.1' port '35381'
* Note: Long running test detection and test timeouts are disabled due to an attached debugger *

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions