Killer NAnt Scripting Quick Tip: <Call> vs. Depends

Don’t use the depends script for everything it is bad form. This is mistake I was doing when I first learned NAnt. Depends has it place, but most times you should use <call> instead of declaring it depends in the target tag. depends should be reserved for use when something has to happen first.

An example of this would be, I have to copy files, but I can’t until I backup my files. You could put the back up call in depends. If you use depends, you lose the ability to call variables in the current task.

How to use <call>:

<!-- Using Depends -->

<target name="task.build" depends="action.build.project, action.copy.to.beta" >

</target>

<!-- Using Call -->

<target name="task.build">   <property name="action.source.dir" value="\\path\to\folder" />     <property name="action.output.dir" value="\\path\to\folder" />     <call target="action.build.project" />     <call target="action.copy.to.beta /></target>

When we use depends, it has to happen before our script runs. Call is more flexible, because you can then scope variables to use with the tasks you are calling, and it does not control the structure of your scripting.

View All of the Killer Nant Scripting Articles

Post a Comment

Your email is never shared. Required fields are marked *

*
*
Profile Picture

About Ian Lintner


I am a software developer, mostly web,  in Des Moines, Iowa. I take a very opinionated stand concerning development, you will never regret a simple design or architecture. My education was at Drake University in Biology and Computer Science. Offline I am recently married to my wife Heather. I try my hand at many hobbies currently I am gardening till the snow comes in.



My Current Projects


Des Moines Twitter Trends