Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public override bool Execute ()
foreach (var assembly in Assemblies)
res.Load (Path.GetFullPath (assembly.ItemSpec));

var strippedAssemblies = new Dictionary<string, string> ();
foreach (var assemblyName in Assemblies) {
var suffix = assemblyName.ItemSpec.EndsWith (".dll") ? String.Empty : ".dll";
string hintPath = assemblyName.GetMetadata ("HintPath").Replace (Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radekdoulik @jonpryor won't this fail if the assembly is readonly. I can't remember if we fix those up before we run this task or not

File.Move (pair.Value, pair.Key);
Log.LogDebugMessage (" The stripped library {0} is moved back to {1}", pair.Value, pair.Key);
}

return true;
}
}
Expand Down