John Hardin wrote:

Is there any way to dump the contents of a fileset? I'd like to verify
that it's doing what I want it to do, and I don't see a "verbose"
parameter on it or any task that will list its contents.



OK - I've whipped up a couple of custom functions using the script task to inspect the contents of a fileset. Heres the script :

<script language="C#" prefix="fileset" >
       <imports>
           <import namespace="NAnt.Core.Types"/>
       </imports>
       <code>
       <![CDATA[
       [Function("contains")]
       public bool Contains( string fsetID, string filepath ) {
           bool found = false;
           FileSet fset = (FileSet)Project.DataTypeReferences[fsetID];
           if ( fset != null ) {
               if ( fset.FileNames.Contains( filepath ) ) {
                   found = true;
               }
           }
           return found;
       }
       [Function("to-string")]
       public string Contains( string fsetID ) {
           StringBuilder results = new StringBuilder();
           FileSet fset = (FileSet)Project.DataTypeReferences[fsetID];
           if ( fset != null ) {
               foreach ( string file in fset.FileNames ) {
                   results.Append( file + Environment.NewLine );
               }
           }
           return results.ToString();
       }
       ]]>
       </code>
   </script>

and use the functions like:
<fileset id="foo">
<include name="*.resx"/>
</fileset> <echo message="${fileset::to-string('foo')}"/>
<echo message="result of fileset::contains is: ${fileset::contains('foo', 'myfile.resx' )}"/>


You'll need to be running a 0.85 series NAnt build.
Enjoy,

Ian

btw - I quite like the idea of prototyping functions/tasks in script tags before considering them for inclusion in NAnt. Maybe we should add a user-submitted scripts section on the wiki.




------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Nant-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to