From 22c459854bc1ddb60e7f8084117b2db9cdbaa815 Mon Sep 17 00:00:00 2001 From: Rowan Marchant-Williams <--local> Date: Thu, 17 Jul 2025 21:54:30 +0100 Subject: [PATCH] Fix 2095 update stale env var with process.env vars --- src/Components/TestExplorer.fs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Components/TestExplorer.fs b/src/Components/TestExplorer.fs index 24857432..732ed9af 100644 --- a/src/Components/TestExplorer.fs +++ b/src/Components/TestExplorer.fs @@ -557,6 +557,14 @@ module DotnetCli = let argString = String.Join(" ", args) logger.Debug($"Running `dotnet {argString}`") + let getEnv enableTestHostDebugger = + let parentEnv = Node.Api.``process``.env + let childEnv = parentEnv + //NOTE: Important to include VSTEST_HOST_DEBUG=0 when not debugging to remove stale values + // that may cause the debugger to wait and hang + childEnv?VSTEST_HOST_DEBUG <- (if enableTestHostDebugger then 1 else 0) + childEnv |> box |> Some + match shouldDebug with | Debug -> let mutable isDebuggerStarted = false @@ -571,20 +579,8 @@ module DotnetCli = launchDebugger processId isDebuggerStarted <- true - let env = - let parentEnv = Node.Api.``process``.env - let childEnv = parentEnv - childEnv?VSTEST_HOST_DEBUG <- 1 - childEnv |> box |> Some - - Process.execWithCancel "dotnet" (ResizeArray(args)) env tryLaunchDebugger cancellationToken - | NoDebug -> - let env = - let staleOverrides = {| VSTEST_HOST_DEBUG = 0 |} - staleOverrides |> box |> Some - - Process.execWithCancel "dotnet" (ResizeArray(args)) env ignore cancellationToken - + Process.execWithCancel "dotnet" (ResizeArray(args)) (getEnv true) tryLaunchDebugger cancellationToken + | NoDebug -> Process.execWithCancel "dotnet" (ResizeArray(args)) (getEnv false) ignore cancellationToken type TrxPath = string type ConsoleOutput = string