dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.21k stars 1.35k forks source link

Logger error should be reported to other loggers #6564

Open KirillOsenkov opened 3 years ago

KirillOsenkov commented 3 years ago

Have two loggers: /bl and a misbehaving logger that throws on, say, ProjectStarted.

The build will fail with 0 errors, 0 warnings and this message:

Build FAILED.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.94
MSBUILD : error MSB4017: The build stopped unexpectedly because of an unexpected logger failure.
Microsoft.Build.Exceptions.InternalLoggerException: The build stopped unexpectedly because of an unexpected logger failure. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at MSBuild.Logger.BuildConfiguration.Equals(Object obj)
   at System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y)
   at System.Collections.Generic.List`1.Contains(T item)
   at MSBuild.Logger.ProjectTrees.AddTopLevelProject(ProjectStartedEventArgs startedEvent, BuildConfiguration platformConfiguration)
   at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseProjectStartedEvent(Object sender, ProjectStartedEventArgs buildEvent)
   --- End of inner exception stack trace ---
   at Microsoft.Build.Exceptions.InternalLoggerException.Throw(Exception innerException, BuildEventArgs e, String messageResourceName, Boolean initializationException, String[] messageArgs)
   at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseProjectStartedEvent(Object sender, ProjectStartedEventArgs buildEvent)
   at MSBuild.Logger.ForwardingLogger.ForwardEvent(Object sender, BuildEventArgs e)
   at Microsoft.Build.BackEnd.Logging.EventSourceSink.RaiseProjectStartedEvent(Object sender, ProjectStartedEventArgs buildEvent)

This message is missing from the binlog, so we should probably have a better design around continuing to log into other loggers when one logger crashes. Right now the binlog just contains build failed but no indication of the other logger fault.

KirillOsenkov commented 3 years ago

Discovered while investigating https://github.com/microsoft/azure-pipelines-tasks/issues/14904