Index: DeleteTask.cs
===================================================================
RCS file: /cvsroot/nant/nant/src/NAnt.Core/Tasks/DeleteTask.cs,v
retrieving revision 1.1
diff -u -r1.1 DeleteTask.cs
--- DeleteTask.cs	14 Aug 2002 23:21:51 -0000	1.1
+++ DeleteTask.cs	20 Feb 2003 05:18:06 -0000
@@ -53,19 +53,22 @@
         string _file = null;       
         string _dir = null;               
         FileSet _fileset = new FileSet();
+        bool quiet =  false;
 
-        /// <summary>The file to delete.</summary>
-        [TaskAttribute("file")]
+        /// <summary>
+        /// The file to delete, specified as either the simple filename (if the file exists in the 
+        /// current base directory), a relative-path filename, or a full-path filename.</summary>
+        [TaskAttribute("file", Required=false)]
         public string FileName {
             get { return _file; }
-            set {_file = value; }
+            set { _file = value; }
         }
         
-        /// <summary>The directory to delete.</summary>
-        [TaskAttribute("dir")]
+        /// <summary>The directory to delete, including all its files and subdirectories.</summary>
+        [TaskAttribute("dir", Required=false)]
         public string DirectoryName {
             get { return _dir; }
-            set {_dir = value; }
+            set { _dir = value; }
         }
 
         /// <summary>All the files in the file set will be deleted.</summary>
@@ -74,12 +77,36 @@
             get { return _fileset; }
         }
 
+        /// <summary>
+        /// If the specified file or directory does not exist, do not display a diagnostic message 
+        /// or modify the exit status to reflect an error. When set to "true", if a file or directory 
+        /// cannot be deleted, no error is reported. Default is "false". Setting this to &quot;true&quot; 
+        /// implies setting failonerror to &quot;false&quot;.
+        /// </summary>        
+        [TaskAttribute("quiet", Required=false)]
+        [BooleanValidator()]
+        public bool Quiet {
+            get { return quiet; }
+            set { 
+                quiet = value; 
+
+                if (value) {
+                    FailOnError = false;
+                }
+            }
+        }
+
         protected override void ExecuteTask() {
             // limit task to deleting either a file or a directory or a file set
             if (FileName != null && DirectoryName != null) {
                 throw new BuildException("Cannot specify 'file' and 'dir' in the same delete task.", Location);
             }
 
+            // the quiet and failonerror attributes cannot both be set to true
+            if (Quiet && FailOnError) {
+                throw new BuildException("quiet and failonerror cannot both be set to true.", Location);
+            }
+
             if (FileName != null) {
                 // try to delete specified file
                 string path = null;
@@ -89,7 +116,7 @@
                     string msg = String.Format("Could not determine path from {0}", FileName);
                     throw new BuildException(msg, Location, e);
                 }
-                DeleteFile(path, true);
+                DeleteFile(path);
 
             } else if (DirectoryName != null) {
                 // try to delete specified directory
@@ -101,16 +128,20 @@
                     throw new BuildException(msg, Location, e);
                 }
                 DeleteDirectory(path);
-
             } else {
                 // delete files in fileset
                 Log.WriteLine(LogPrefix + "Deleting {0} files", DeleteFileSet.FileNames.Count);
                 foreach (string path in DeleteFileSet.FileNames) {
-                    DeleteFile(path, Verbose);
+                    DeleteFile(path);
                 }
             }
         }
 
+        /// <summary>
+        /// Deletes the specified directory.
+        /// </summary>
+        /// <param name="path">The full path of the directory that should be deleted.</param>
+        /// <exception cref="BuildException">The directory cannot be deleted and <see cref="Task.FailOnError" /> is set to <c>true</c>.</exception>
         void DeleteDirectory(string path) {
             try {
                 if (Directory.Exists(path)) {
@@ -119,31 +150,45 @@
                         throw new NotImplementedException("Path is too close to root to delete.");
                     }
 
-                    Log.WriteLine(LogPrefix + "Deleting directory {0}", path);
+                    Log.WriteLineIf(Verbose, LogPrefix + "Deleting directory {0}", path);
                     Directory.Delete(path, true);
                 } else {
-                    throw new DirectoryNotFoundException();
+                    // only log this warning when quiet is "false" or the build was started with the
+                    // -verbose switch
+                    Log.WriteLineIf(!Quiet || Project.Verbose, LogPrefix + "Cannot delete directory {0}.  The directory does not exist.", path);
                 }
             } catch (Exception e) {
+                string msg = String.Format("Cannot delete directory {0}.", path);
+
                 if (FailOnError) {
-                    string msg = String.Format("Cannot delete directory {0}", path);
                     throw new BuildException(msg, Location, e);
+                } else {
+                    Log.WriteLineIf(!Quiet, LogPrefix + msg);
                 }
             }
         }
 
-        void DeleteFile(string path, bool verbose) {
+        /// <summary>
+        /// Deletes the specified file.
+        /// </summary>
+        /// <param name="path">The full path of the file that should be deleted.</param>
+        /// <exception cref="BuildException">The file cannot be deleted and <see cref="Task.FailOnError" /> is set to <c>true</c>.</exception>
+        void DeleteFile(string path) {
             try {
                 if (File.Exists(path)) {
-                    Log.WriteLineIf(verbose, LogPrefix + "Deleting file {0}", path);
+                    Log.WriteLineIf(Verbose, LogPrefix + "Deleting file {0}", path);
                     File.Delete(path);
                 } else {
-                    throw new FileNotFoundException();
+                    // only log this warning when quiet is "false" or the build was started with the
+                    // -verbose switch
+                    Log.WriteLineIf(!Quiet || Project.Verbose, LogPrefix + "Cannot delete file {0}. The file does not exist.", path);
                 }
             } catch (Exception e) {
+                string msg = String.Format("Cannot delete file {0}", path);
                 if (FailOnError) {
-                    string msg = String.Format("Cannot delete file {0}", path);
                     throw new BuildException(msg, Location, e);
+                } else {
+                    Log.WriteLineIf(!Quiet, LogPrefix + msg);
                 }
             }
         }
