From aa2d38d6c1cb4efe7788c0bfa7b0b109583b96e1 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Mon, 11 May 2015 16:31:44 -0700 Subject: [PATCH] Better error handling --- test/RemoteTest.ps1 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/RemoteTest.ps1 b/test/RemoteTest.ps1 index 74704f2cbf..61d1127d4d 100644 --- a/test/RemoteTest.ps1 +++ b/test/RemoteTest.ps1 @@ -27,14 +27,19 @@ $remoteScript = { cd C:\$using:serverFolder\$using:projectName dir $env:DNX_TRACE=1 - $testResult = & .\test.cmd 2>&1 - $testResult = & $lastexitcode + + $output = & .\test.cmd 2>&1 + $output + $lastexitcode } Write-Host ">>>> Remote code execution started <<<<" -$result = Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock $remoteScript -$result +$remoteJob = Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock $remoteScript -AsJob +Wait-Job $remoteJob Write-Host "<<<< Remote execution code completed >>>>" -$testExitCode = $result[$result.length-1]; -exit $testExitCode +$remoteResult = Receive-Job $remoteJob +$remoteResult + +$finalExitCode = $remoteResult[$remoteResult.Length-1] +exit $finalExitCode