Nested build does not fail

196 views
Skip to first unread message

squillman

unread,
Jul 28, 2010, 1:36:02 PM7/28/10
to psake-users
Hi Everyone,

Hoping someone can shed some light on this.

I have a fairly simple Psake build script (default.ps1) that calls
Invoke-Psake from within one of the tasks. Something like this:

(default.ps1)

. .\utilities.ps1
properties {
...define some properties
}

task default -depends Step1

task Step1 {
Invoke-Psake script2.ps1
}

The second build script has a task and does its thing.

(script2.ps1)

. .\utilities.ps1
properties {
...define properties
}

task default -depends script2.CreateSchema

script2.CreateSchema {
Invoke-Sqlcmd ....(parameters)
}

The tasks work fine; the Invoke-Sqlcmd call works.

The problem I'm facing is if for some reason the script2.CreateSchema
task fails Psake still reports that the build succeeds. The task
failure in the child script is not bubbling up to the parent script
such that Psake fails the build.

Anyone run into this? Is this maybe a problem with the new nested
build feature of Psake?

Psake v4.0
Powershell v2.0

Thanks!

-Shawn Quillman

Mikael Henriksson

unread,
Jul 28, 2010, 2:54:55 PM7/28/10
to psake...@googlegroups.com
Sounds like something similar to my problem http://groups.google.com/group/psake-users/t/85bdc7c66660c41e?hl=en
It was solved with wrapping the executioon in "exec { task }" and the reason was that -"PowerShell doesn't recognize non-zero exit codes from 
executables as an error."

Mikael Henriksson

Tel: +46 (0) 730- 393 200 





--
You received this message because you are subscribed to the Google Groups "psake-users" group.
To post to this group, send email to psake...@googlegroups.com.
To unsubscribe from this group, send email to psake-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psake-users?hl=en.


squillman

unread,
Jul 28, 2010, 4:05:34 PM7/28/10
to psake-users

Yes, it does sound a lot like your problem and I actually did see your
case when troubleshooting. I tried the exec() thing, though, and
still got the same results. I am thinking that because it's a cmdlet
call and not a separate .exe that something's still amiss. I'll try
the exec() bit again, though. Maybe I missed something...

-Shawn

On Jul 28, 2:54 pm, Mikael Henriksson <mik...@zoolutions.se> wrote:
> Sounds like something similar to my problemhttp://groups.google.com/group/psake-users/t/85bdc7c66660c41e?hl=en
> It was solved with wrapping the executioon in "exec { task }" and the reason
> was that -"PowerShell doesn't recognize non-zero exit codes from
> executables as an error."
>
> Mikael Henriksson
>
> Tel: +46 (0) 730- 393 200
> mik...@zoolutions.se
>
> > psake-users...@googlegroups.com<psake-users%2Bunsu...@googlegroups.com>
> > .

Jorge Matos

unread,
Jul 29, 2010, 10:09:46 AM7/29/10
to psake...@googlegroups.com
Shawn,
 
That's a use case that I didn't test when I wrote the nested builds feature! 
 
I believe the issue is related to the fact that a new scope is implicitly created when the nested call is made.  I was able to re-produce the issue with the psake example nested.ps1.
 
I changed nested1.ps1 to the following:
 
Properties {
 $x = 100
}
Task default -Depends Nested1CheckX
 
Task Nested1CheckX {
 #Assert ($x -eq 100) '$x was not 100'
 throw "oops!"
}
 
 
 and the calling script nested.ps1 did not fail - but if you change the main script to use exec() it does fail. 
 
Here's the nested.ps1 script:
 
Properties {
 $x = 1
}
 
Task default -Depends RunNested1, RunNested2, CheckX
 
Task RunNested1 {
 exec { Invoke-psake .\nested\nested1.ps1 }
}
 
Task RunNested2 {
 Invoke-psake .\nested\nested2.ps1
}
 
Task CheckX{
 Assert ($x -eq 1) '$x was not 1'
}

 
I will investigate this further and let you all know

 
To unsubscribe from this group, send email to psake-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/psake-users?hl=en.




--
Jorge Matos
Senior .NET Architect, MCSD.NET, MCSD Visual Studio 6.0
(440) 666-3107
matos...@hotmail.com     
Blog: http://matosjorge.spaces.live.com
--------------------------------------------------------------------------------
"Any intelligent fool can make things bigger and more complex...
It takes a touch of genius - and a lot of courage to
move in the opposite direction."... - Albert Einstein

squillman

unread,
Jul 29, 2010, 11:10:44 AM7/29/10
to psake-users
Hi Jorge,

Oh good, I'm glad to hear that and that it's not me just missing
something! I tried what you suggested and wrapped the Invoke-Psake
call in my parent script (default.ps1) in an exec() call and the build
does indeed fail now. Thank you very much for the response and I look
forward to seeing what you come up with!

-Shawn

On Jul 29, 10:09 am, Jorge Matos <matos.jo...@gmail.com> wrote:
> Shawn,
>
> That's a use case that I didn't test when I wrote the nested builds
> feature!
>
> I believe the issue is related to the fact that a new scope is implicitly
> created when the nested call is made.  I was able to re-produce the issue
> with the psake example nested.ps1.
>
> I changed nested1.ps1 to the following:
>
> > Properties {
> >  $x = 100
> > }
> > Task default -Depends Nested1CheckX
>
> > Task Nested1CheckX {
> >  #Assert ($x -eq 100) '$x was not 100'
> >  throw "oops!"
> > }
>
>  and the calling script nested.ps1 did not fail - but if you change the main
> script to use exec() it does fail.
>
> Here's the nested.ps1 script:
>
>
>
>
>
> > Properties {
> >  $x = 1
> > }
>
> > Task default -Depends RunNested1, RunNested2, CheckX
>
> > Task RunNested1 {
> >  *exec *{ Invoke-psake .\nested\nested1.ps1 }
> > > > psake-users...@googlegroups.com<psake-users%2Bunsubscribe@googlegr oups.com>
> > <psake-users%2Bunsu...@googlegroups.com<psake-users%252Bunsubscribe@goo glegroups.com>
>
> >  > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/psake-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "psake-users" group.
> > To post to this group, send email to psake...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > psake-users...@googlegroups.com<psake-users%2Bunsubscribe@googlegr oups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/psake-users?hl=en.
>
> --
> Jorge Matos
> Senior .NET Architect, MCSD.NET <http://mcsd.net/>, MCSD Visual Studio 6.0
> (440) 666-3107
> matos_jo...@hotmail.com
> Blog:http://matosjorge.spaces.live.com
> --------------------------------------------------------------------------- -----
Reply all
Reply to author
Forward
0 new messages