diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs index 6395bb3c051..0fc1f9ce810 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs @@ -117,7 +117,7 @@ bool RunAapt (string commandLine) using (var proc = new Process ()) { proc.OutputDataReceived += (sender, e) => { if (e.Data != null) - LogEventsFromTextOutput (e.Data, MessageImportance.Normal); + LogMessage (e.Data, MessageImportance.Normal); else stdout_completed.Set (); }; @@ -369,7 +369,7 @@ protected void LogEventsFromTextOutput (string singleLine, MessageImportance mes int line = 0; if (!string.IsNullOrEmpty (match.Groups["line"]?.Value)) line = int.Parse (match.Groups["line"].Value) + 1; - var level = match.Groups["level"].Value; + var level = match.Groups["level"].Value.ToLowerInvariant (); var message = match.Groups ["message"].Value; if (message.Contains ("fakeLogOpen") || level.Contains ("warning")) { LogWarning (singleLine); @@ -388,17 +388,13 @@ protected void LogEventsFromTextOutput (string singleLine, MessageImportance mes if (message.StartsWith ("error: ", StringComparison.InvariantCultureIgnoreCase)) message = message.Substring ("error: ".Length); - LogError ("APT0000", message, file, line); - return; - } - - // Handle additional error that doesn't match the regex - if (singleLine.Trim ().StartsWith ("invalid resource directory name:")) { - LogError ("APT0000", string.Format ("Invalid resource directory name: \"{0}\".", singleLine.Substring (singleLine.LastIndexOfAny (new char[] { '\\', '/' }) + 1)), ToolName); - return; + if (level.Contains ("error") || (line != 0 && !string.IsNullOrEmpty (file))) { + LogError ("APT0000", message, file, line); + return; + } } - LogMessage (singleLine, messageImportance); + LogError ("APT0000", string.Format("{0} \"{1}\".", singleLine.Trim(), singleLine.Substring(singleLine.LastIndexOfAny(new char[] { '\\', '/' }) + 1)), ToolName); } } } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidToolTask.cs b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidToolTask.cs index 18f66b83916..df800aa6433 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidToolTask.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidToolTask.cs @@ -105,7 +105,7 @@ public static Regex AndroidErrorRegex { \s* (?.*) $ -", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); +", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase); return androidErrorRegex; } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidRegExTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidRegExTests.cs index ab9162330f0..d47a3e0ccc0 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidRegExTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidRegExTests.cs @@ -58,7 +58,70 @@ public IEnumerator GetEnumerator () /*expectedLevel*/ "", /*expectedMessage*/ "Invalid file name: must contain only [a-z0-9_.]" }; - + yield return new object [] { + /*message*/ "max res 10, skipping values-sw600dp", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "", + /*expectedMessage*/ "max res 10, skipping values-sw600dp" + }; + yield return new object [] { + /*message*/ "max res 10, skipping values-sw600dp-land", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "", + /*expectedMessage*/ "max res 10, skipping values-sw600dp-land" + }; + yield return new object [] { + /*message*/ "Error: unable to generate entry for resource data", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "Error", + /*expectedMessage*/ "unable to generate entry for resource data" + }; + yield return new object [] { + /*message*/ "Error: malformed resource filename", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "Error", + /*expectedMessage*/ "malformed resource filename" + }; + yield return new object [] { + /*message*/ "warning: Multiple AndroidManifest.xml files found, using foo\\AndroidManifest.xml", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "warning", + /*expectedMessage*/ "Multiple AndroidManifest.xml files found, using foo\\AndroidManifest.xml" + }; + yield return new object [] { + /*message*/ "Resources/values/theme.xml:55: No start tag found", + /*expectedToMatch*/ true, + /*expectedFile*/ "Resources/values/theme.xml", + /*expectedLine*/ "55", + /*expectedLevel*/ "", + /*expectedMessage*/ "No start tag found" + }; + yield return new object [] { + /*message*/ "package name is required with --rename-manifest-package.", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "", + /*expectedMessage*/ "package name is required with --rename-manifest-package." + }; + yield return new object [] { + /*message*/ "invalid resource directory name: bar-55", + /*expectedToMatch*/ true, + /*expectedFile*/ "", + /*expectedLine*/ "", + /*expectedLevel*/ "", + /*expectedMessage*/ "invalid resource directory name: bar-55" + }; } }