Getting $LastExitCode in PowerShell when invoking Visual Build using PowerShell

Viewed 2560

I want to invoke a VisualBuild build from PowerShell and get it's last exit code.

I invoke the Build using.

Start-Process -FilePath $VisualBuild -ArgumentList "/b Somescript.bld" -PassThru -NoNewWindow

I already tried using try catch mechanism but this lead my LastExitCode to be 0 even if the Build Failed.

When using something like

$BuildProcess = Start-Process -FilePath $VisualBuild -ArgumentList "/b Somescript.bld" -PassThru -NoNewWindow
Write-Host "$($BuildProcess.ExitCode)"

my Script get's stuck after executing and displaying that the Build has failed but the Output of the LastExitCode is never displayed.

The $VisualBuild Variable holds the full Path to the VisBuildCmd.exe

1 Answers
Related