-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[msbuild] Improve altool task by logging execution errors #6815
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ | |
|
||
using Microsoft.Build.Utilities; | ||
using Microsoft.Build.Framework; | ||
using System.Text; | ||
|
||
namespace Xamarin.MacDev.Tasks | ||
{ | ||
public abstract class ALToolTaskBase : ToolTask | ||
{ | ||
string sdkDevPath; | ||
StringBuilder toolOutput; | ||
|
||
public string SessionId { get; set; } | ||
|
||
|
@@ -40,6 +42,17 @@ string DevicePlatformBinDir { | |
get { return Path.Combine (SdkDevPath, "usr", "bin"); } | ||
} | ||
|
||
public override bool Execute () | ||
{ | ||
toolOutput = new StringBuilder (); | ||
|
||
base.Execute (); | ||
|
||
LogErrorsFromOutput (toolOutput.ToString ()); | ||
|
||
return !HasLoggedErrors; | ||
} | ||
|
||
protected override string GenerateFullPathToTool () | ||
{ | ||
if (!string.IsNullOrEmpty (ToolPath)) | ||
|
@@ -70,6 +83,7 @@ protected override string GenerateCommandLineCommands () | |
|
||
protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance) | ||
{ | ||
toolOutput.Append (singleLine); | ||
Log.LogMessage (messageImportance, "{0}", singleLine); | ||
} | ||
|
||
|
@@ -82,5 +96,28 @@ string GetFileTypeValue () | |
default: throw new NotSupportedException ($"Provided file type '{FileType}' is not supported by altool"); | ||
} | ||
} | ||
|
||
void LogErrorsFromOutput (string output) | ||
{ | ||
try { | ||
if (string.IsNullOrEmpty(output)) | ||
return; | ||
|
||
var plist = PObject.FromString (output) as PDictionary; | ||
var errors = PObject.Create (PObjectType.Array) as PArray; | ||
var message = PObject.Create (PObjectType.String) as PString; | ||
|
||
if ((plist?.TryGetValue ("product-errors", out errors) == true)) { | ||
foreach (var error in errors) { | ||
var dict = error as PDictionary; | ||
if (dict?.TryGetValue ("message", out message) == true) { | ||
Log.LogError (ToolName, null, null, null, 0, 0, 0, 0, "{0}", message.Value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if the API (or some overloads) allows it but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spouliot What if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, bring us back to not sure if the API :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I don't really like it (using |
||
} | ||
} | ||
} | ||
} catch (Exception ex) { | ||
Log.LogWarning ("Failed to parse altool output: {0}", ex.Message); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should you include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also |
||
} | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary space change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: space before
(