foreach errors if the path is empty

Help
2003-03-28
2004-05-06
  • Michael Hirsch
    Michael Hirsch
    2003-03-28

    I'm trying to do bundle up some files, if they exist.  So I create a path with include="**/CDM/*.sql" and iterate with foreach on that path.

    This works fine if there is at least one file matching that pattern.  But if there is no such file I get:
    You must have a list or path to iterate through
    and the build fails.

    Is there a standard workaround for this?  Is there a way to tell when the path is empty?

    This behavior seems non-intuitive.  It seems to me like foreach should just do nothing if there is nothing in its list or path.  It should just be an empty iterator.

     
    • John Hopkins
      John Hopkins
      2004-02-17

      Why not surround the foreach with the 'if' task?

      What do you mean by "bundle up"?  Can you not use the 'zip' task?

       
    • Matt Inger
      Matt Inger
      2004-05-06

      foreach now works correctly if the path yields no entries.