Executing a task from inside another task

745 views
Skip to first unread message

Joshua Poehls

unread,
Mar 4, 2010, 11:58:00 AM3/4/10
to psake-users
Is there a way to execute a task from inside another task? I would
like to do the following:

# how i'd like to do it
#################
task default -depends Step1

task Step1 {
# do something

exec Step2

# do something else
}

task Step2 {
# do something
}

Right now I can achieve this by putting the logic for Step2 inside a
function and then calling that function from Step1 and Step2. See
below for an example of this. I would just like to remove the function
if possible.

# how i can do it now
##################
task default -depends Step1

task Step1 {
# do something

Step2Function()

# do something else
}

task Step2 {
Step2Function()
}

function Step2Function() {
# do something
}

zi makki

unread,
Mar 4, 2010, 1:18:35 PM3/4/10
to psake...@googlegroups.com
You could achieve this by splitting out the tasks in a more fine grained tasks and ruining them via the depend task property.

task default -doSomething, Step2, doSomethingElse{
}

It feels a bit "smelly" to call tasks from within tasks. Open for a discussion! :)

Hope this helps.

Zi





--
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.


Joshua Poehls

unread,
Mar 4, 2010, 7:11:29 PM3/4/10
to psake...@googlegroups.com
I have to agree with the smelly comment. It may be that its best to do this via the -depend or the function method rather than have a feature that encourages smelly code :)

I think this was a case of me trying to make my psake script too-closely resemble my MSBuild script.

- Joshua Poehls
Reply all
Reply to author
Forward
0 new messages