Exemplo n.º 1
0
        private void PrintSummary(StopBuildEvent @event)
        {
            var maxLength = @event.Build.Targets.Max(x => x.Name.Length);
            var anyFailed = @event.Build.Targets.Any(x => x.Status == TargetExecutionStatus.Failed);
            var color     = ConsoleColor.Green;

            if (anyFailed)
            {
                color = ConsoleColor.Red;
            }

            Write(color, "");
            Write(color, "---------------------------------------------------------------------");
            Write(color, "Build Time Report");
            Write(color, "---------------------------------------------------------------------");
            Write(color, "Target".PadRight(maxLength) + "    Duration");
            Write(color, "------".PadRight(maxLength) + "    --------");
            foreach (var target in @event.Build.Targets)
            {
                var text = target.Name.PadRight(maxLength + 4) + target.Duration.ToString();
                switch (target.Status)
                {
                case TargetExecutionStatus.Failed:
                    Write(ConsoleColor.Red, target.Name.PadRight(maxLength + 4) + "Failed");
                    break;

                case TargetExecutionStatus.NotRun:
                    Write(ConsoleColor.DarkGray, target.Name.PadRight(maxLength + 4) + "Not Run");
                    break;

                case TargetExecutionStatus.Skipped:
                    Write(ConsoleColor.Yellow, target.Name.PadRight(maxLength + 4) + "Skipped");
                    break;

                case TargetExecutionStatus.Success:
                    Write(ConsoleColor.Green, target.Name.PadRight(maxLength + 4) + target.Duration.ToString());
                    break;
                }
            }
            Write(color, "------".PadRight(maxLength) + "    --------");
            var status = anyFailed
                ? "Failed"
                : "Ok";

            Write(color, "Result".PadRight(maxLength + 4) + status);
            Write(color, "---------------------------------------------------------------------");
        }
Exemplo n.º 2
0
        private void Handle(StopBuildEvent @event)
        {
            WriteDuration();
            _writer.WriteEndElement();
            _writer.Flush();
            _writer.Close();
            _writer.Dispose();
            _writer = null;

            string filename;

            if (!_session.Parameters.TryGetValue(OutputPathParameterName, out filename))
            {
                filename = "build-output.xml";
            }

            File.WriteAllText(filename, _buffer.ToString());
        }