diff --git a/src/Uno.SourceGeneration.Protocol/Helpers/BinaryLoggerReplayHelper.cs b/src/Uno.SourceGeneration.Protocol/Helpers/BinaryLoggerReplayHelper.cs index b468863..3f3f9ca 100644 --- a/src/Uno.SourceGeneration.Protocol/Helpers/BinaryLoggerReplayHelper.cs +++ b/src/Uno.SourceGeneration.Protocol/Helpers/BinaryLoggerReplayHelper.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Text; using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; namespace Uno.SourceGeneration.Helpers { @@ -11,17 +12,26 @@ namespace Uno.SourceGeneration.Helpers /// /// Replays the provided binlog file in the current build engine /// - public static void Replay(IBuildEngine engine, string filePath) + public static void Replay(IBuildEngine engine, string filePath, TaskLoggingHelper log) { if (File.Exists(filePath)) { - var replaySource = new Microsoft.Build.Logging.BinaryLogReplayEventSource(); + try + { + var replaySource = new Microsoft.Build.Logging.BinaryLogReplayEventSource(); - replaySource.MessageRaised += (s, e) => engine.LogMessageEvent(e); - replaySource.WarningRaised += (s, e) => engine.LogWarningEvent(e); - replaySource.ErrorRaised += (s, e) => engine.LogErrorEvent(e); + replaySource.MessageRaised += (s, e) => engine.LogMessageEvent(e); + replaySource.WarningRaised += (s, e) => engine.LogWarningEvent(e); + replaySource.ErrorRaised += (s, e) => engine.LogErrorEvent(e); - replaySource.Replay(filePath); + replaySource.Replay(filePath); + } + catch(Exception e) + { + var fileSize = File.Exists(filePath) ? new FileInfo(filePath).Length : -1; + + log.LogWarning($"Failed to replay source generation controller build messages (path:{filePath}, size:{fileSize}) : {e}"); + } } } } diff --git a/src/Uno.SourceGeneratorTasks.Dev15.0/Tasks/SourceGenerationTask.cs b/src/Uno.SourceGeneratorTasks.Dev15.0/Tasks/SourceGenerationTask.cs index e72a1c7..278d798 100644 --- a/src/Uno.SourceGeneratorTasks.Dev15.0/Tasks/SourceGenerationTask.cs +++ b/src/Uno.SourceGeneratorTasks.Dev15.0/Tasks/SourceGenerationTask.cs @@ -217,7 +217,7 @@ namespace Uno.SourceGeneratorTasks responseTask.Wait(_sharedCompileCts.Token); - BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile); + BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile, Log); if (responseTask.Result.Type == GenerationResponse.ResponseType.Completed) { @@ -340,7 +340,7 @@ namespace Uno.SourceGeneratorTasks process.WaitForExit(); } - BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile); + BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile, Log); if (process.ExitCode == 0) {