NAnt
![]() ![]() ![]() |
v0.91 |
Deletes a file, fileset or directory.
Deletes either a single file, all files in a specified directory and its sub-directories, or a set of files specified by one or more filesets.
If the file
or dir
attribute is set then the fileset contents will be ignored. To delete the files in the fileset ommit the file
and dir
attributes in the <delete>
element.
If the specified file or directory does not exist, no error is reported.
Note: Read-only files cannot be deleted. Use the <attrib> task first to remove the read-only attribute.
Attribute | Type | Description | Required |
---|---|---|---|
dir | directory | The directory to delete. | False |
file | file | The file to delete. | False |
includeemptydirs | bool | Remove any empty directories included in the <fileset>. The default is true. | False |
verbose | bool | Controls whether to show the name of each deleted file or directory. The default is false. | False |
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 |
Delete a single file.
<delete file="myfile.txt" />
Delete a directory and the contents within. If the directory does not exist, no error is reported.
<delete dir="${build.dir}" />
Delete a set of files.
<delete> <fileset> <include name="${basename}-??.exe" /> <include name="${basename}-??.pdb" /> </fileset> </delete>