diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs b/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs index a79f8328af7..95054b2889b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs @@ -32,6 +32,7 @@ public override bool Execute () foreach (var assembly in Assemblies) res.Load (Path.GetFullPath (assembly.ItemSpec)); + var strippedAssemblies = new Dictionary (); foreach (var assemblyName in Assemblies) { var suffix = assemblyName.ItemSpec.EndsWith (".dll") ? String.Empty : ".dll"; string hintPath = assemblyName.GetMetadata ("HintPath").Replace (Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); @@ -68,7 +69,8 @@ public override bool Execute () } } if (assembly_modified) { - Log.LogDebugMessage (" The stripped library is saved as {0}", assemblyPath); + var strippedPath = assemblyPath + ".stripped"; + Log.LogDebugMessage (" The stripped library is saved as {0}", strippedPath); // Output assembly needs to regenerate symbol file even if no IL/metadata was touched // because Cecil still rewrites all assembly types in Cecil order (type A, nested types of A, type B, etc) @@ -77,9 +79,19 @@ public override bool Execute () WriteSymbols = assembly.MainModule.HasSymbols }; - assembly.Write (assemblyPath, wp); + assembly.Write (strippedPath, wp); + strippedAssemblies [assemblyPath] = strippedPath; } } + + res.Dispose (); + + foreach (var pair in strippedAssemblies) { + File.Delete (pair.Key); + File.Move (pair.Value, pair.Key); + Log.LogDebugMessage (" The stripped library {0} is moved back to {1}", pair.Value, pair.Key); + } + return true; } }