Better error handling

This commit is contained in:
Victor Hurdugaci 2015-05-11 16:31:44 -07:00
parent 0593c0def7
commit aa2d38d6c1
1 changed files with 11 additions and 6 deletions

View File

@ -27,14 +27,19 @@ $remoteScript = {
cd C:\$using:serverFolder\$using:projectName cd C:\$using:serverFolder\$using:projectName
dir dir
$env:DNX_TRACE=1 $env:DNX_TRACE=1
$testResult = & .\test.cmd 2>&1
$testResult = & $lastexitcode $output = & .\test.cmd 2>&1
$output
$lastexitcode
} }
Write-Host ">>>> Remote code execution started <<<<" Write-Host ">>>> Remote code execution started <<<<"
$result = Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock $remoteScript $remoteJob = Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock $remoteScript -AsJob
$result Wait-Job $remoteJob
Write-Host "<<<< Remote execution code completed >>>>" Write-Host "<<<< Remote execution code completed >>>>"
$testExitCode = $result[$result.length-1]; $remoteResult = Receive-Job $remoteJob
exit $testExitCode $remoteResult
$finalExitCode = $remoteResult[$remoteResult.Length-1]
exit $finalExitCode