Does anybody know how I could create a recursive loop with NAnt? I need to loop through all of my folders and upload the files to our webserver. I am using this NAnt ftp task (http://www.spinthemoose.com/~ftptask), however it doesn't seem to upload the entire directory. It uploads only the mentioned files in my put element.
Thanks,
Foreach task. You can find examples looping through folders.
Full example:
<foreach item="Folder" property="foldername">
<in>
<items>
<include name="YOUR_FOLDER\**" />
</items>
</in>
<do>
<foreach item="File" property="filename" in="${foldername}">
<do>
<echo message="${filename}" />
</do>
</foreach>
</do>
</foreach>
If you do not need folders, you can achieve your needs even with less code:
<foreach item="File" property="filename">
<in>
<items>
<include name="YOUR_FOLDER\**" />
</items>
</in>
<do>
<echo message="${filename}" />
</do>
</foreach>
I believe this should give you the recursive list of folders
<?xml version="1.0"?>
<target name="task.recursive">
<foreach item="Folder" in="${folder.current}" property="folder">
<echo message="${folder}" />
<property name="folder.current" value="${folder}" />
<call target="task.recursive" />
</foreach>
</target>
<target name="task.run">
<echo message="${project.folder.root}" level="Info" />
<property name="folder.current" value="${project.folder.root}" />
<call target="task.recursive" />
</target>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With