Example #1
0
        /// <summary>
        /// Writes a string to the feedback target output, extracting any build message found in the string.
        /// </summary>
        /// <param name="value">The string to write</param>
        public override void Write(string value)
        {
            if (!string.IsNullOrWhiteSpace(value) && this.MessageMapping != null)
            {
                foreach (var mapping in this.MessageMapping)
                {
                    if (value.StartsWith(mapping.Key))
                    {
                        var description = value.Substring(mapping.Key.Length).Trim();

                        var message = new BuildMessage()
                        {
                            Type        = mapping.Value,
                            Description = description
                        };

                        if (this.activeTask != null)
                        {
                            message.Configuration = this.activeTask.Configuration;
                            message.Project       = this.activeTask.ProjectName;
                        }

                        this.FeedbackTarget.AddMessage(message);

                        break;
                    }
                }
            }

            base.Write(value);
        }
Example #2
0
 public void AddMessage(BuildMessage message)
 {
     this.Messages.Add(message);
 }
Example #3
0
        /// <summary>
        /// Executes a collection of build tasks using the specified feedback object.
        /// </summary>
        /// <param name="tasks">An array of build tasks to execute.</param>
        /// <returns>The build result for all tasks.</returns>
        public virtual IBuildResult Build(IBuildTask[] tasks, IBuildFeedback feedback)
        {
            if (tasks == null)
            {
                throw new ArgumentNullException("tasks");
            }

            if (feedback == null)
            {
                throw new ArgumentNullException("feedback");
            }

            var result = new BuildResult()
            {
                Success = true,
                TotalSteps = tasks.Length
            };

            foreach (var task in tasks)
            {
                try
                {
                    feedback.WriteLine("------ Build started: {0} ------", task.ToString());

                    result.Success = this.BuildTask(task, feedback);

                    feedback.WriteLine();
                }
                catch (Exception x)
                {
                    var message = new BuildMessage(x)
                    {
                        Project = task.ProjectName,
                        Configuration = task.Configuration
                    };

                    feedback.AddMessage(message);

                    result.Success = false;
                }

                if (result.Success)
                {
                    result.TasksSuccesful++;
                }
                else
                {
                    feedback.Write("aborting build... ");

                    result.TasksAborted++;

                    break;
                }
            }

            if (!result.Success)
            {
                feedback.WriteLine("aborted!");
                feedback.WriteLine();
            }

            feedback.WriteLine(
                "========== Build: {1} succeeded, {2} failed, {3} skipped ==========",
                result.Success ? "succeeded" : "failed",
                result.TasksSuccesful,
                result.TasksAborted,
                result.TasksSkipped,
                result.TotalSteps);

            return result;
        }
Example #4
0
        /// <summary>
        /// Writes a string to the feedback target output, extracting any build message found in the string.
        /// </summary>
        /// <param name="value">The string to write</param>
        public override void Write(string value)
        {
            if (!string.IsNullOrWhiteSpace(value) && this.MessageMapping != null)
            {
                foreach (var mapping in this.MessageMapping)
                {
                    if (value.StartsWith(mapping.Key))
                    {
                        var description = value.Substring(mapping.Key.Length).Trim();

                        var message = new BuildMessage()
                        {
                            Type = mapping.Value,
                            Description = description
                        };

                        if (this.activeTask != null)
                        {
                            message.Configuration = this.activeTask.Configuration;
                            message.Project = this.activeTask.ProjectName;
                        }

                        this.FeedbackTarget.AddMessage(message);

                        break;
                    }
                }
            }

            base.Write(value);
        }
Example #5
0
 public void AddMessage(BuildMessage message)
 {
     this.Messages.Add(message);
 }
Example #6
0
        /// <summary>
        /// Executes a collection of build tasks using the specified feedback object.
        /// </summary>
        /// <param name="tasks">An array of build tasks to execute.</param>
        /// <returns>The build result for all tasks.</returns>
        public virtual IBuildResult Build(IBuildTask[] tasks, IBuildFeedback feedback)
        {
            if (tasks == null)
            {
                throw new ArgumentNullException("tasks");
            }

            if (feedback == null)
            {
                throw new ArgumentNullException("feedback");
            }

            var result = new BuildResult()
            {
                Success    = true,
                TotalSteps = tasks.Length
            };

            foreach (var task in tasks)
            {
                try
                {
                    feedback.WriteLine("------ Build started: {0} ------", task.ToString());

                    result.Success = this.BuildTask(task, feedback);

                    feedback.WriteLine();
                }
                catch (Exception x)
                {
                    var message = new BuildMessage(x)
                    {
                        Project       = task.ProjectName,
                        Configuration = task.Configuration
                    };

                    feedback.AddMessage(message);

                    result.Success = false;
                }

                if (result.Success)
                {
                    result.TasksSuccesful++;
                }
                else
                {
                    feedback.Write("aborting build... ");

                    result.TasksAborted++;

                    break;
                }
            }

            if (!result.Success)
            {
                feedback.WriteLine("aborted!");
                feedback.WriteLine();
            }

            feedback.WriteLine(
                "========== Build: {1} succeeded, {2} failed, {3} skipped ==========",
                result.Success ? "succeeded" : "failed",
                result.TasksSuccesful,
                result.TasksAborted,
                result.TasksSkipped,
                result.TotalSteps);

            return(result);
        }