Merge pull request #799 from kebby/master
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / RemoveDir.cs
index f1aaac7f1c03da0042ee564a71b0e3a948927108..00755fc449666dea161d6df4359bd5751acaba99 100644 (file)
@@ -45,30 +45,18 @@ namespace Microsoft.Build.Tasks {
 
                public override bool Execute ()
                {
+                       if (directories.Length == 0)
+                               return true;
+
                        List <ITaskItem> temporaryRemovedDirectories = new List <ITaskItem> ();
                        
                        foreach (ITaskItem directory in directories) {
                                try {
-                                       Directory.Delete (directory.GetMetadata ("FullPath"), true);
-                                       temporaryRemovedDirectories.Add (directory);
-                               }
-                               catch (DirectoryNotFoundException ex) {
-                                       Log.LogErrorFromException (ex);
-                               }
-                               catch (PathTooLongException ex) {
-                                       Log.LogErrorFromException (ex);
-                               }
-                               catch (ArgumentNullException ex) {
-                                       Log.LogErrorFromException (ex);
-                               }
-                               catch (ArgumentException ex) {
-                                       Log.LogErrorFromException (ex);
-                               }
-                               catch (IOException ex) {
-                                       Log.LogErrorFromException (ex);
-                               }
-                               catch (SecurityException ex) {
-                                       Log.LogErrorFromException (ex);
+                                       string fullpath = directory.GetMetadata ("FullPath");
+                                       if (Directory.Exists (fullpath)) {
+                                               Directory.Delete (fullpath, true);
+                                               temporaryRemovedDirectories.Add (directory);
+                                       }
                                }
                                catch (Exception ex) {
                                        Log.LogErrorFromException (ex);
@@ -102,4 +90,4 @@ namespace Microsoft.Build.Tasks {
        }
 }
 
-#endif
\ No newline at end of file
+#endif