Filesets are groups of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of patterns. Filesets can appear inside tasks that support this feature or at the project level, i.e., as children of <project>
.
For a list of all members of this type, see FileSet Members.
System.Object
NAnt.Core.Element
NAnt.Core.DataTypeBase
NAnt.Core.Types.FileSet
Derived types
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
As described earlier, patterns are used for the inclusion and exclusion. These patterns look very much like the patterns used in DOS and UNIX:
'*
' matches zero or more characters
For example:
*.cs
matches .cs
, x.cs
and FooBar.cs
, but not FooBar.xml
(does not end with .cs
).
'?
' matches one character
For example:
?.cs
matches x.cs
, A.cs
, but not .cs
or xyz.cs
(both don't have one character before .cs
).
Combinations of *
's and ?
's are allowed.
Matching is done per-directory. This means that first the first directory in the pattern is matched against the first directory in the path to match. Then the second directory is matched, and so on. For example, when we have the pattern /?abc/*/*.cs
and the path /xabc/foobar/test.cs
, the first ?abc
is matched with xabc
, then *
is matched with foobar
, and finally *.cs
is matched with test.cs
. They all match, so the path matches the pattern.
To make things a bit more flexible, we added one extra feature, which makes it possible to match multiple directory levels. This can be used to match a complete directory tree, or a file anywhere in the directory tree. To do this, **
must be used as the name of a directory. When **
is used as the name of a directory in the pattern, it matches zero or more directories. For example: /test/**
matches all files/directories under /test/
, such as /test/x.cs
, or /test/foo/bar/xyz.html
, but not /xyz.xml
.
There is one "shorthand" - if a pattern ends with /
or \
, then **
is appended. For example, mypackage/test/
is interpreted as if it were mypackage/test/**
.
By default, pattern matching is case-sensitive on Unix and case-insensitive on other platforms. The CaseSensitive parameter can be used to override this.
There are a set of definitions that are excluded by default from all tasks that use filesets. They are:
If you do not want these default excludes applied, you may disable them by setting DefaultExcludes to false.
Pattern | Match |
---|---|
**/CVS/* |
Matches all files in Matches:
But not:
|
org/apache/jakarta/** |
Matches all files in the Matches:
But not:
|
org/apache/**/CVS/* |
Matches all files in Matches:
But not:
|
**/test/** |
Matches all files that have a |
Namespace: NAnt.Core.Types
Assembly: NAnt.Core (in NAnt.Core.dll)
FileSet Members | NAnt.Core.Types Namespace | PatternSet