/// <summary>
        /// Replays the provided binlog file in the current build engine
        /// </summary>
        public static void Replay(IBuildEngine engine, string filePath)
        {
            if (File.Exists(filePath))
            {
                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.Replay(filePath);
            }
        }
Example #2
0
        /// <summary>
        /// Replays the provided binlog file in the current build engine
        /// </summary>
        public static void Replay(IBuildEngine engine, string filePath, TaskLoggingHelper log)
        {
            if (File.Exists(filePath))
            {
                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.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}");
                }
            }
        }