diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/RemoveUnknownFiles.cs b/src/Xamarin.Android.Build.Tasks/Tasks/RemoveUnknownFiles.cs index 157cc512363..28a2253f640 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/RemoveUnknownFiles.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/RemoveUnknownFiles.cs @@ -54,7 +54,7 @@ public override bool RunTask () continue; } var files = System.IO.Directory.GetFiles (absDir, "*", SearchOption.AllDirectories); - foreach (string f in files) + foreach (string f in files) { if (!knownFiles.Contains (f)) { Log.LogDebugMessage ("Deleting File {0}", f); var item = new TaskItem (f.Replace (absDir, root + Path.DirectorySeparatorChar)); @@ -62,18 +62,20 @@ public override bool RunTask () Microsoft.Android.Build.Tasks.Files.SetWriteable (f); File.Delete (f); } + } if (RemoveDirectories) { var knownDirs = new HashSet (knownFiles.Select (d => Path.GetDirectoryName (d))); var dirs = System.IO.Directory.GetDirectories (absDir, "*", SearchOption.AllDirectories); - foreach (string d in dirs.OrderByDescending (s => s.Length)) + foreach (string d in dirs.OrderByDescending (s => s.Length)) { if (!knownDirs.Contains (d) && IsDirectoryEmpty (d)) { Log.LogDebugMessage ("Deleting Directory {0}", d); removedDirectories.Add (new TaskItem(d)); Microsoft.Android.Build.Tasks.Files.SetDirectoryWriteable (d); System.IO.Directory.Delete (d); } + } } }