Log each inner exception of an aggregate exception in TaskLoggingHelper.LogErrorFromException()#7998
Conversation
…er.LogErrorFromException()
Forgind
left a comment
There was a problem hiding this comment.
LGTM. The bug mentions InvalidProjectFileException as well; do you think it's worth leaving it open until that part is also resolved?
The only way to make it work with the I could use Reflection if anyone would approve of that 😈 |
|
I'm curious how much work it'd be to make M.B.Utilities reference M.B. Probably not worth it. |
You'd need to have all of these compiled only into Microsoft.Build: msbuild/src/Utilities/Microsoft.Build.Utilities.csproj Lines 43 to 149 in cc3db35 Then you'd need to update the ones that compile themselves into a different namespace depending on the project: msbuild/src/Shared/TaskLoggingHelper.cs Lines 21 to 25 in cc3db35 I have this memory of trying it years ago but I can't remember now exactly why |
|
I love the idea of removing all those extra compilations. Adding new dependencies between our assemblies can be very efficient, but that issue reminded me of what happened when I added a direct reference to Framework in SolutionFile.cs: someone had been calling Parse without loading Framework, and it suddenly started needing Framework --> their scenario crashed. I'd love to add the dependency, but now I'm worried it would be ugly work to make a breaking change we'd end up reverting. |
Fixes #7985
Context
TaskLoggingHelper.LogErrorFromException()does not currently take into account the relatively newAggregateExceptionwhich has inner exceptions but an outer exception with very little details.Changes Made
I've updated
TaskLoggingHelper.LogErrorFromException()to check if the specified exception is anAggregateExceptionand call the method again for each inner exception, respecting all of the arguments passed in around showing details or a stack trace.Testing
A unit test was added
Notes
Unfortunately, I can't add the other improvement around an
InvalidProjectFileExceptionsinceTaskLoggingHelperis compiled intoMicrosoft.Build.Utilities.Coreand that assembly does not referenceMicrosoft.Build.dllso it doesn't have access to theInvalidProjectFileExceptionclass 😢