This is untested code, but you could do something like this ... I bet with
some modifications you could get your results. Hope it helps someone :-)
// usage: <echo message="${string::sort-fileset('filesetid')}" />
[FunctionSet("string", "String")]
public class SortFilesetFunctions : FunctionSetBase
{
public SortFilesetFunctions(Project project, PropertyDictionary properties) :
base(project, properties) { }
[Function("sort-fileset")]
public void SortFileset(String pFilesetId)
{
if (pFilesetId.Length > 0)
{
FileSet fs = GetFileSetByID(pFilesetId);
String[] t_array = new String[fs.FileNames.Count];
fs.FileNames.CopyTo(t_array, fs.FileNames.Count);
// Sort your array however your wish
Array.Sort(t_array);
}
else
{
throw new Exception("FileSet ID is empty");
}
}
public FileSet GetFileSetByID(String pID)
{
if (pID.Length > 0)
{
DataTypeBase dtb = this.Project.DataTypeReferences[pID];
return (FileSet)dtb;
}
throw new Exception("FileSet ID is empty");
}
}
-Alan
> From: [EMAIL PROTECTED]> Date: Thu, 3 May 2007 17:31:04 -0500> To: [EMAIL
> PROTECTED]> CC: nant-users@lists.sourceforge.net> Subject: Re: [NAnt-users]
> Sorting fileset> > Seems a bit heavy handed. I took a cursory glance through
> the NAnt > source, and I'm not sure how I would go about extending something
> > like fileset. Anyone know if there is a way to write a custom task, > like
> <foreach>, that would allow me to iterate over items and still > use existing
> NAnt tasks to perform actions on them? I would hate to > lose all of the
> other NAnt functionality by creating one giant custom > task.> > Griffin
> Caprio> 312.371.3869> http://blog.1530technologies.com> > > > On May 3, 2007,
> at 5:21 PM, Craig Beck wrote:> > > Write a fileset-like component like
> sequenced-fileset?> >> > -----Original Message-----> > From: [EMAIL
> PROTECTED]> > [mailto:[EMAIL PROTECTED] On Behalf Of Griffin> > Caprio> >
> Sent: Thursday, May 03, 2007 3:18 PM> > To: Ryan Anthony> > Cc:
> nant-users@lists.sourceforge.net> > Subject: Re: [NAnt-users] Sorting
> fileset> >> > So let's say that's not an option.> >> > Is there anything else
> I can do?> >> > Griffin Caprio> > 312.371.3869> >
> http://blog.1530technologies.com> >> >> >> > On May 3, 2007, at 4:08 PM, Ryan
> Anthony wrote:> >> >> I believe the quick and dirty answer is to add a zero
> in front of > >> each> >> single digit number.> >>> >> Ryan> >>> >> Griffin
> Caprio wrote:> >>> Hello all,> >>>> >>> I am trying to iterate through a
> directory of files that are> >>> numerically named:> >>>> >>> 1.sql> >>>
> 2.sql> >>> ...> >>>> >>> Using the foreach task is easy:> >>>> >>> <foreach
> item="File" property="loop.filepath">> >>> <in>> >>> <items>> >>> <include
> name="**.sql" />> >>> </items>> >>> </in>> >>> <do>> >>> <echo
> message="${loop.filepath}"/>> >>> </do>> >>> </foreach>> >>>> >>> However,
> this returns the list of files, sorted in text fashion, not> >>> numerically.
> For example, if 10.sql was in the directory, it would> >>> be returned before
> 2.sql. Obviously, since these files need to be> >>> run in order, this won't
> do.> >>>> >>> Is there anyway I can accomplish this?> >>>> >>> Thanks,> >>>
> Griffin Caprio> >>>> >>>> >>>> >>>> >>>> >>>> >>>
> -------------------------------------------------------------------- > >>> ->
> >> >>> ----> >>> This SF.net email is sponsored by DB2 Express> >>> Download
> DB2 Express C - the FREE version of DB2 express and take> >>> control of your
> XML. No limits. Just data. Click to get it now.> >>>
> http://sourceforge.net/powerbar/db2/> >>>
> _______________________________________________> >>> NAnt-users mailing list>
> >>> NAnt-users@lists.sourceforge.net> >>>
> https://lists.sourceforge.net/lists/listinfo/nant-users> >>>> >>> __________
> NOD32 2238 (20070503) Information __________> >>>> >>> This message was
> checked by NOD32 antivirus system.> >>> http://www.eset.com> >>>> >>>> >>>>
> >> >> >
> ---------------------------------------------------------------------- > >
> --> > -> > This SF.net email is sponsored by DB2 Express> > Download DB2
> Express C - the FREE version of DB2 express and take> > control of your XML.
> No limits. Just data. Click to get it now.> >
> http://sourceforge.net/powerbar/db2/> >
> _______________________________________________> > NAnt-users mailing list> >
> NAnt-users@lists.sourceforge.net> >
> https://lists.sourceforge.net/lists/listinfo/nant-users> > >
> ------------------------------------------------------------------------->
> This SF.net email is sponsored by DB2 Express> Download DB2 Express C - the
> FREE version of DB2 express and take> control of your XML. No limits. Just
> data. Click to get it now.> http://sourceforge.net/powerbar/db2/>
> _______________________________________________> NAnt-users mailing list>
> NAnt-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/nant-users
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users