psake/psake — Issue #23: MSTest Failure not failing build; exit code 1
Author: toddhgardner
Created: 2011-11-04 21:02:12+00:00
State: open

MSTest forces the exit code of Invoke-PSake to 1 if any test fails, regardless of ContinueOnError.

If I have a script such as:

```powershell
Task test -ContinueOnError {
exec { & MSTest /testcontainer:Failing.UnitTests.dll }
}
```

That I invoke with a batch file such as:

```batch
powershell.exe -Version 2 -NoProfile -ExecutionPolicy unrestricted -Command "& {cls; Import-Module '.\psake\psake.psm1'; invoke-psake .\test.ps1 -framework 4.0 %*; if (($lastexitcode -ne 0) -and ($lastexitcode -ne $null)) {write-host "ERROR: $lastexitcode" -fore RED; exit $lastexitcode} }"
```

I get a result:

```
Build Succeeded!

----------------------------------------------------------------------
Build Time Report
----------------------------------------------------------------------
Name Duration
---- --------
test 00:00:02.4978145
Total: 00:00:02.5227254
ERROR: 1
```

I have a pull request that solves this issue, will be sending shortly