diff --git a/src/UnitTests.Shared/MockLogger.cs b/src/UnitTests.Shared/MockLogger.cs index c07a43b58a5..d9a72966a81 100644 --- a/src/UnitTests.Shared/MockLogger.cs +++ b/src/UnitTests.Shared/MockLogger.cs @@ -307,7 +307,7 @@ public void LoggerEventHandler(object sender, BuildEventArgs eventArgs) bool logMessage = !(eventArgs is BuildFinishedEventArgs) || LogBuildFinished; if (logMessage) { - string msg = eventArgs.Message; + string msg = eventArgs.Message ?? $"(null message in {eventArgs.GetType().Name} event)"; if (eventArgs is BuildMessageEventArgs m && m.LineNumber != 0) { msg = $"{m.File}({m.LineNumber},{m.ColumnNumber}): {msg}";