How to echo the contents of a fileset in Nant

nant

Was trying to do something like this:

<copy>  
        <fileset id="mySet">
        <include name="*.sql" />
    </fileset>
</copy>
<echo message="Copied files: ${mySet} to directory: ${Folder}." />

But i get the following error:

'id' is an invalid attribute for a
tag. Datatypes can only be
declared at Project or Target level.
Thanks

Best Answer

You can do this by looping over the files in the set.

<fileset id="mySet">
  <include name="*.sql" />
</fileset>
<copy>  
  <fileset refid="mySet" />
</copy>
<foreach item="File" property="filename">
  <in>
    <items refid="mySet" />
  </in>
  <do>
    <echo message="Copied files: ${filename} to directory: ${Folder}." />
  </do>
</foreach>

But depending on verbosity level the result of the copy action is echoed anyway.

Related Topic