Getting $LastExitCode in PowerShell when invoking Visual Build using PowerShell

Home / Uncategorized / Getting $LastExitCode in PowerShell when invoking Visual Build using PowerShell

Question:
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


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *