Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


MSTest Failure not failing build; exit code 1 #23

toddhgardner opened this Issue · 1 comment

2 participants


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

If I have a script such as:

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

That I invoke with a batch file such as:

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

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

@whut whut referenced this issue from a commit in whut/psake
whut Fix for issue #23 - psake.cmd should exit with 0 when build succeeded
Also use of -ExecutionPolicy Bypass, which is even less restrictive than -ExecutionPolicy Unrestricted

GitHub automatically created another issue, #24 when you created pull request, check comment there.

@whut whut closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.