Open Source .NET Development [Electronic resources]

Brian Nantz

نسخه متنی -صفحه : 275/ 140
نمايش فراداده

<foreach>Loops over a set of Items.

Can loop over files in directory, lines in a file, etc.

The Property value is stored before the loop is done and restored when the loop is finished. The Property is returned to its normal value once it is used.

Attribute

Description

Required

property

The NAnt property name that should be used for the current iterated item.

True

item

The type of iteration that should be done.

True

in

The source of the iteration.

True

delim

The deliminator char.

False

failonerror

Determines whether task failure stops the build or is just reported. Default is "true."

False

verbose

Task reports detailed build log messages. Default is "false."

False

if

If true then the task will be executed; otherwise skipped. Default is "true."

False

unless

Opposite of if. If false then the task will be executed; otherwise skipped. Default is "false."

False

Loops over the files in C:\

Example

<foreach item="File" in="c:\" property="filename"> <echo message="${filename}"/> </foreach>

Loops over the folders in C:\

Example

<foreach item="Folder" in="c:\" property="foldername"> <echo message="${foldername}"/> </foreach>

Loops over a list

Example

<foreach item="String" in="1 2 3" delim=" " property="count"> <echo message="${count}"/> </foreach>