[xbuild] RemoveDir - remove only if the dir exists.
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / RemoveDir.cs
index 54ab566321821779c85e8dd6dd626f0700848cbf..32505c9a42474e75607b634af19b255eeab69f36 100644 (file)
@@ -52,11 +52,11 @@ namespace Microsoft.Build.Tasks {
                        
                        foreach (ITaskItem directory in directories) {
                                try {
-                                       Directory.Delete (directory.GetMetadata ("FullPath"));
-                                       temporaryRemovedDirectories.Add (directory);
-                               }
-                               catch (DirectoryNotFoundException ex) {
-                                       Log.LogErrorFromException (ex);
+                                       string fullpath = directory.GetMetadata ("FullPath");
+                                       if (Directory.Exists (fullpath)) {
+                                               Directory.Delete (fullpath, true);
+                                               temporaryRemovedDirectories.Add (directory);
+                                       }
                                }
                                catch (PathTooLongException ex) {
                                        Log.LogErrorFromException (ex);