HasLoggedError Respects MSBuildWarningsAsErrors#5957
HasLoggedError Respects MSBuildWarningsAsErrors#5957benvillalobos wants to merge 5 commits intodotnet:masterfrom
Conversation
|
Note to self: Look over warningsaserror tests and figure out when the collections I'm checking aren't null. It looks like LoggingContext should be able to determine on its own that a warning its about to log should actually be an error. |
270c9f3 to
d1acd05
Compare
|
Correctly fixing this is proving to be quite difficult. The warnings in the repro are logging from a Task, which logs to a TaskLoggingHelper, which logs a warning through a BuildEngine. The BuildEngine (through TaskHost.cs) tells a loggingcontext's LoggingService that it's logged a warning. The problem is a TaskLoggingHelper has no idea that when it logs a warning it's actually being logged as an error. Funny thing is this problem also exists for LoggingContext. I solved that by exposing the Thinking out loud: could we create an IBuildEngine8 that had an event called Other questions I've thought up while investigating this: Have Tasks never correctly respected Log.HasLoggedError when we throw a warning and that warning is included in MSBuildWarningsAsErrors? Note to self: see the PR that introduced it: #1928 |
|
The PR that introduced warning-as-error is #1355--#1928 extended it to allow the project level properties. Since that's done in the logging infrastructure rather than at the point of logging, I think that's the problem. Unfortunately I don't know if there's an easy way to move it. Can you investigate that angle? Is the warning-as-errors stuff available in TaskHost and if not how hard would it be to get it there? I don't think we should attack the problem for TaskLoggingHelper alone--if you attack it at the IBuildEngine API layer, it'll work for everything, not just tasks that use the helper classes. |
|
Sorry, undrafted by accident. |
|
Closing in favor of: #6040 |
Fixes #5511
Context
Custom tasks have a
Log.HasLoggedErrorsproperty that does not respect thrown warnings that are listed underMSBuildWarningsAsErrors.The Solution
Before logging the warning, check if the warning code is listed under
MSBuildWarningsAsErrors. If so, log as an error instead.Notes
Some comments I wrote as I was investigating this, in all its unformatted glory
To-Do