NAntContrib Help Task Reference <grep> | v0.92-beta1 |
[This is preliminary documentation and subject to change.]
Searches files for a regular-expression and produces an XML report of the matches.
Attribute | Type | Description | Required |
---|---|---|---|
output | file | Specifies the name of the output file. | True |
pattern | string | Specifies the regular-expression to search for. | True |
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False |
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False |
unless | bool | Opposite of if . If false then the task will be executed; otherwise, skipped. The default is false. |
False |
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False |
Extract all TODO:, UNDONE: or HACK:- comment-tags from C# source files and write them to a file out.xml. (A xslt-stylesheet could then transform it to a nice html-page for your project-homepage, but that is beyond the scope of this example.)
Path, File and LineNumber are automatically generated elements.
<grep output="out.xml" pattern="// (?'Type'TODO|UNDONE|HACK): (\[(?'Author'\w*),(?'Date'.*)\])? (?'Text'[^\n\r]*)"> <fileset> <include name="*.cs" /> </fileset> </grep>
The resulting XML file for a comment-tag 'TODO: [md, 14-02-2004] comment this method' will look like
<?xml version="1.0" encoding="utf-8" ?> <Matches> <Match> <Type>TODO</Type> <Text>comment this method</Text> <Path>C:\MyProjects\MyPath</Path> <File>MyFile.cs</Filename> <LineNumber>146</LineNumber> <Author>md</Author> <Date>14-02-2004</Date> </Match> ... </Matches>