Skip to content

Commit 22c4598

Browse files
author
Rowan Marchant-Williams
committed
Fix 2095 update stale env var with process.env vars
1 parent 33376ab commit 22c4598

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Components/TestExplorer.fs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ module DotnetCli =
557557
let argString = String.Join(" ", args)
558558
logger.Debug($"Running `dotnet {argString}`")
559559

560+
let getEnv enableTestHostDebugger =
561+
let parentEnv = Node.Api.``process``.env
562+
let childEnv = parentEnv
563+
//NOTE: Important to include VSTEST_HOST_DEBUG=0 when not debugging to remove stale values
564+
// that may cause the debugger to wait and hang
565+
childEnv?VSTEST_HOST_DEBUG <- (if enableTestHostDebugger then 1 else 0)
566+
childEnv |> box |> Some
567+
560568
match shouldDebug with
561569
| Debug ->
562570
let mutable isDebuggerStarted = false
@@ -571,20 +579,8 @@ module DotnetCli =
571579
launchDebugger processId
572580
isDebuggerStarted <- true
573581

574-
let env =
575-
let parentEnv = Node.Api.``process``.env
576-
let childEnv = parentEnv
577-
childEnv?VSTEST_HOST_DEBUG <- 1
578-
childEnv |> box |> Some
579-
580-
Process.execWithCancel "dotnet" (ResizeArray(args)) env tryLaunchDebugger cancellationToken
581-
| NoDebug ->
582-
let env =
583-
let staleOverrides = {| VSTEST_HOST_DEBUG = 0 |}
584-
staleOverrides |> box |> Some
585-
586-
Process.execWithCancel "dotnet" (ResizeArray(args)) env ignore cancellationToken
587-
582+
Process.execWithCancel "dotnet" (ResizeArray(args)) (getEnv true) tryLaunchDebugger cancellationToken
583+
| NoDebug -> Process.execWithCancel "dotnet" (ResizeArray(args)) (getEnv false) ignore cancellationToken
588584

589585
type TrxPath = string
590586
type ConsoleOutput = string

0 commit comments

Comments
 (0)