diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets
index ce005fa8959..8827e1ceb51 100644
--- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets
+++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Aapt2.targets
@@ -244,6 +244,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
+
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs
index cf3b0fc3384..c70cfb09fb7 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs
@@ -4,6 +4,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Text;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
@@ -79,8 +80,8 @@ public class Aapt2Link : Aapt2 {
AssemblyIdentityMap assemblyMap = new AssemblyIdentityMap ();
List tempFiles = new List ();
+ SortedSet rulesFiles = new SortedSet ();
Dictionary apks = new Dictionary ();
- string proguardRuleOutputTemp;
protected override int GetRequiredDaemonInstances ()
{
@@ -92,8 +93,6 @@ public async override System.Threading.Tasks.Task RunTaskAsync ()
try {
assemblyMap.Load (Path.Combine (WorkingDirectory, AssemblyIdentityMapFile));
- proguardRuleOutputTemp = GetTempFile ();
-
await this.WhenAll (ManifestFiles, ProcessManifest);
ProcessOutput ();
@@ -120,8 +119,19 @@ public async override System.Threading.Tasks.Task RunTaskAsync ()
}
}
}
- if (!string.IsNullOrEmpty (ProguardRuleOutput))
- Files.CopyIfChanged (proguardRuleOutputTemp, ProguardRuleOutput);
+ if (!string.IsNullOrEmpty (ProguardRuleOutput)) {
+ // combine the "proguard" temp files into one file.
+ var sb = new StringBuilder ();
+ sb.AppendLine ("#Auto Generated file. Do not Edit.");
+ lock (rulesFiles) {
+ foreach (var file in rulesFiles) {
+ sb.AppendLine ($"# Data from {file}");
+ foreach (var line in File.ReadLines (file))
+ sb.AppendLine (line);
+ }
+ }
+ Files.CopyIfStringChanged (sb.ToString (), ProguardRuleOutput);
+ }
} finally {
lock (tempFiles) {
foreach (var temp in tempFiles) {
@@ -285,7 +295,7 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s
if (!string.IsNullOrEmpty (ProguardRuleOutput)) {
cmd.Add ("--proguard");
- cmd.Add (GetFullPath (proguardRuleOutputTemp));
+ cmd.Add (GetFullPath (GetManifestRulesFile (manifestDir)));
}
cmd.Add ("-o");
cmd.Add (GetFullPath (currentResourceOutputFile));
@@ -341,6 +351,14 @@ void ProcessManifest (ITaskItem manifestFile)
}
}
+ string GetManifestRulesFile (string manifestDir)
+ {
+ string rulesFile = Path.Combine (manifestDir, "aapt_rules.txt");
+ lock (rulesFiles)
+ rulesFiles.Add (rulesFile);
+ return rulesFile;
+ }
+
string GetTempFile ()
{
var temp = Path.GetTempFileName ();