-
Notifications
You must be signed in to change notification settings - Fork 515
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
Conversation
The altool task was just logging the XML output produced by the tool execution but was not logging any build error neither failing in that case.
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 feedback
} | ||
} | ||
} 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Should you include output
in the exception log ?
That way you can get a clue of what went wrong
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.
also $"Failed to parse altool output: {ex.Message}"
looks nicer :)
void LogErrorsFromOutput (string output) | ||
{ | ||
try { | ||
if (string.IsNullOrEmpty(output)) |
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 (
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 comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if the API (or some overloads) allows it but "{0}"
seems to require a call to String.Format
, can't you just provide message.Value
?
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.
@spouliot What if message.Value
contains something that can be a format string? Say "{0}"
for instance, then things might fail (depending on LogError's implementation).
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.
yeah, bring us back to not sure if the API :)
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.
yes, I don't really like it (using "{0}"
) but it seems to be safer, and that's how most of the XI tasks log errors that come from tool outputs or text we don't control.
Build success |
} |
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.
Unnecessary space change
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 comment
The reason will be displayed to describe this comment to others. Learn more.
@spouliot What if message.Value
contains something that can be a format string? Say "{0}"
for instance, then things might fail (depending on LogError's implementation).
Build failure 🔥 Build failed 🔥 |
build |
1 similar comment
build |
Build success |
@rolfbjarne could you review the latest changes? Is there anything else needed to get this PR merged? |
The altool task was just logging the XML output produced by the tool execution but was not logging any build error neither failing in that case.