psake saying Build Succeeded when msbuild returns exit code 1 wrapped in exec {}

348 views
Skip to first unread message

Stéphane Erbrech

unread,
Jan 16, 2014, 5:06:26 AM1/16/14
to psake...@googlegroups.com
Hi,

It's not like I have never struggled with this, I have a whole blog post about this http://alsagile.com/post/27403222324/using-psake-to-run-your-teamcity-continuous-integration
and we had a discussion on that forum (https://groups.google.com/forum/#!topic/psake-users/G6jEJvATz4E)

But somehow I can't get psake to fail again...


Here is how I call psake :

param($task = "default", $parameters=@{})

$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
remove-module [p]sake -erroraction silentlycontinue

import-module "$scriptDir\scripts\psake\psake.psm1"
$psake.use_exit_on_error = $true
invoke-psake "$scriptDir\default.ps1" $task -parameters $parameters


my task look like this :

task Package-Core {
    $project_path = "AK.Core/AK.Core.csproj"
    $core_package_location = "$($deploy_package_root)\AK.Core\\"
    exec { msbuild $project_path /P:VisualStudioVersion=12.0`;OutDir=$core_package_location`;Configuration="Deploy-Dev" /T:Build }
}


and here is the resulting output when run from the powershell console.

.\build.ps1 package-core
                                                                                                                       
psake version 4.3.0
Copyright (c) 2010 James Kovacs

WARNING: The names of some imported commands from the module 'teamcity' include unapproved verbs that might make them less discoverable. To find the commands with unappro
ved verb
WARNING: s, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
##teamcity[progessMessage 'Running task package-core']
Executing package-core
Microsoft (R) Build Engine version 4.0.30319.18408
[Microsoft .NET Framework, version 4.0.30319.18408]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 16.01.2014 11:01:19.
Project "C:\Src\Campaign Tool\main\src\AK.Core\AK.Core.csproj" on node 1 (Build target(s)).
C:\windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'AK.Core.csproj'.  Please check t
o make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Deploy-Dev'  Platform='AnyCPU'.  You may be seein
g this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this
project. [C:\Src\Campaign Tool\main\src\AK.Core\AK.Core.csproj]
Done Building Project "C:\Src\Campaign Tool\main\src\AK.Core\AK.Core.csproj" (Build target(s)) -- FAILED.

Build FAILED.

"C:\Src\Campaign Tool\main\src\AK.Core\AK.Core.csproj" (Build target) (1) ->
(_CheckForInvalidConfigurationAndPlatform target) ->
  C:\windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'AK.Core.csproj'.  Please check
 to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Deploy-Dev'  Platform='AnyCPU'.  You may be see
ing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for thi
s project. [C:\Src\Campaign Tool\main\src\AK.Core\AK.Core.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.21

Build Succeeded!

----------------------------------------------------------------------
Build Time Report
----------------------------------------------------------------------
Name         Duration       
----         --------       
Package-Core 00:00:01.6995298
Total:       00:00:01.7662002

Time Elapsed 00:00:01.18

[DBG]: PS C:\Src\Campaign Tool\main\src>> $LASTEXITCODE
1




So, What's going on? Isn't it what exec is supposed to do?



Stéphane Erbrech

unread,
Jan 16, 2014, 5:11:49 AM1/16/14
to psake...@googlegroups.com
Oh, just checked the source now,
and I see the exec {} method was changed between 4.3.0 and 4.3.1.
So, it was completely broken in 4.3.0 and not checking lastexit code...

Great. Lost a morning on this.
Reply all
Reply to author
Forward
0 new messages