I want to use NAnt's foreach to iterate files in a folder, how to force alphabetic iteration?

build, foreach, nant, sql-order-by

Solution

FAIL:

<fileset basedir="source\tsql\builds\" id="buildfiles">
  <include name="*.sql.template.sql" /> 
  <exclude name="*.sql" /> 
  <exclude name="*asSentTo*" />
</fileset>
<foreach item="File" property"filename">
  <in refid="buildfiles">
    <echo message="${filename}" /> 
  </in>
</foreach>

PASS:

<foreach item="File" property="filename" in="source\tsql\builds"> 
  <do> 
    <if test="${string::ends-with(filename,'.sql.template.sql')}"> 
      <echo message="${filename}" /> 
    </if> 
  </do> 
</foreach>

Problem

I have an NAnt task "ship" to package my current .sql scripts into a build, then name the build with an incrementing int {######} and copy it to a build folder. I have another NAnt task which executes those build scripts. They must execute in order, but in my last attempt, they were not. Can I "force" NAnt to work alphabetically?

Original source