Example #1
0
        /// <inheritdoc />
        protected override bool BuildTask(IBuildTask task, IBuildFeedback feedback)
        {
            if (this.cabwizTextWriter != null)
            {
                this.cabwizTextWriter.SetActiveTask(task);
            }

            try
            {
                var cabwizTask = task as ICabwizBuildTask;
                if (cabwizTask != null)
                {
                    return(cabwizTask.Build(this.Cabwiz, feedback));
                }
                else
                {
                    return(base.BuildTask(task, feedback));
                }
            }
            finally
            {
                if (this.cabwizTextWriter != null)
                {
                    this.cabwizTextWriter.SetActiveTask(null);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Builds the project according to the current profile.
        /// </summary>
        /// <param name="cabwiz">The cabwiz application reference</param>
        /// <param name="feedback">The build context.</param>
        /// <returns>A value indicating whether the build was successful.</returns>
        public bool Build(Cabwiz.CabwizApplication cabwiz, IBuildFeedback feedback)
        {
            var project = this.Profile.ProjectInfo;
            var profile = this.Profile;

            if (cabwiz == null)
            {
                throw new ArgumentNullException("cabwiz", "Missing reference to a CabwizApplication object.");
            }

            var output = project.GetOutput(profile);

            // Create the .INF file for Cabwiz to process.
            var inf = output.CreateCabwizInf(profile);

            // Set the output directory
            cabwiz.DestinationDirectory = project.GetOutputDirectory(profile);

            // add some feedback
            feedback.WriteLine("   > {0}", cabwiz.PreviewCommandLine(inf));

            int exitCode = cabwiz.Run(inf);

            if (exitCode != 0)
            {
                feedback.WriteLine("   {0} returned {1}", System.IO.Path.GetFileName(cabwiz.FileName), exitCode);

                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #3
0
        /// <inheritdoc />
        public override IBuildResult Build(IBuildTask[] tasks, IBuildFeedback feedback)
        {
            // Wrap the feedback object to a textwriter instance so we may channel
            // the output from the cabwiz.exe application to the feedback object.
            this.cabwizTextWriter = new CabwizTextWriter(feedback);

            this.Cabwiz.StandardOutput = this.cabwizTextWriter;
            this.Cabwiz.StandardError = this.cabwizTextWriter;

            return base.Build(tasks, feedback);
        }
Example #4
0
        /// <inheritdoc />
        public override IBuildResult Build(IBuildTask[] tasks, IBuildFeedback feedback)
        {
            // Wrap the feedback object to a textwriter instance so we may channel
            // the output from the cabwiz.exe application to the feedback object.
            this.cabwizTextWriter = new CabwizTextWriter(feedback);

            this.Cabwiz.StandardOutput = this.cabwizTextWriter;
            this.Cabwiz.StandardError  = this.cabwizTextWriter;

            return(base.Build(tasks, feedback));
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the FeedbackTextWriter class using the specified feedback object as the underlying output target and the specified encoding.
        /// </summary>
        /// <param name="feedback">The feedback object</param>
        /// <param name="encoding">The encoding</param>
        public FeedbackTextWriter(IBuildFeedback feedback, Encoding encoding)
        {
            if (feedback == null)
            {
                throw new ArgumentNullException("feedback");
            }

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

            this.FeedbackTarget = feedback;
            this.encoding       = encoding;
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the FeedbackTextWriter class using the specified feedback object as the underlying output target and the specified encoding.
        /// </summary>
        /// <param name="feedback">The feedback object</param>
        /// <param name="encoding">The encoding</param>
        public FeedbackTextWriter(IBuildFeedback feedback, Encoding encoding)
        {
            if (feedback == null)
            {
                throw new ArgumentNullException("feedback");
            }

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

            this.FeedbackTarget = feedback;
            this.encoding = encoding;
        }
Example #7
0
        /// <inheritdoc />
        protected override bool BuildTask(IBuildTask task, IBuildFeedback feedback)
        {
            if (this.cabwizTextWriter != null)
            {
                this.cabwizTextWriter.SetActiveTask(task);
            }

            try
            {
                var cabwizTask = task as ICabwizBuildTask;
                if (cabwizTask != null)
                {
                    return cabwizTask.Build(this.Cabwiz, feedback);
                }
                else
                {
                    return base.BuildTask(task, feedback);
                }
            }
            finally
            {
                if (this.cabwizTextWriter != null)
                {
                    this.cabwizTextWriter.SetActiveTask(null);
                }
            }
        }
Example #8
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 #9
0
 /// <summary>
 /// Executes the Build method of the specified task.
 /// </summary>
 /// <param name="task">The build task to execute.</param>
 /// <param name="feedback">The feedback object.</param>
 /// <returns>The value returned by the task's Build method.</returns>
 protected virtual bool BuildTask(IBuildTask task, IBuildFeedback feedback)
 {
     return task.Build(feedback);
 }
Example #10
0
 /// <inheritdoc />
 bool IBuildTask.Build(IBuildFeedback feedback)
 {
     // this will ALWAYS result in a ArgumentNullException, but we cannot proceed without cabwiz
     return this.Build(null, feedback);
 }
Example #11
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 #12
0
 /// <summary>
 /// Initializes a new instance of the CabwizTextWriter class.
 /// </summary>
 /// <param name="feedback">The feedback target</param>
 /// <param name="encoding">The encoding to use</param>
 public CabwizTextWriter(IBuildFeedback feedback, Encoding encoding)
     : base(feedback, encoding)
 {
     this.InitializeMapping();
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the CabwizTextWriter class, using UTF-8 encoding.
 /// </summary>
 /// <param name="feedback">The feedback target</param>
 public CabwizTextWriter(IBuildFeedback feedback)
     : base(feedback)
 {
     this.InitializeMapping();
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the CabwizTextWriter class.
 /// </summary>
 /// <param name="feedback">The feedback target</param>
 /// <param name="encoding">The encoding to use</param>
 public CabwizTextWriter(IBuildFeedback feedback, Encoding encoding)
     : base(feedback, encoding)
 {
     this.InitializeMapping();
 }
Example #15
0
 /// <inheritdoc />
 bool IBuildTask.Build(IBuildFeedback feedback)
 {
     // this will ALWAYS result in a ArgumentNullException, but we cannot proceed without cabwiz
     return(this.Build(null, feedback));
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the CabwizTextWriter class, using UTF-8 encoding.
 /// </summary>
 /// <param name="feedback">The feedback target</param>
 public CabwizTextWriter(IBuildFeedback feedback)
     : base(feedback)
 {
     this.InitializeMapping();
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the FeedbackTextWriter class using the specified feedback object as the underlying output target, using UTF-8 encoding.
 /// </summary>
 /// <param name="feedback">The feedback object</param>
 public FeedbackTextWriter(IBuildFeedback feedback)
     : this(feedback, Encoding.UTF8)
 {
     // nothing else to do here.
 }
Example #18
0
        /// <summary>
        /// Builds the project according to the current profile.
        /// </summary>
        /// <param name="cabwiz">The cabwiz application reference</param>
        /// <param name="feedback">The build context.</param>
        /// <returns>A value indicating whether the build was successful.</returns>
        public bool Build(Cabwiz.CabwizApplication cabwiz, IBuildFeedback feedback)
        {
            var project = this.Profile.ProjectInfo;
            var profile = this.Profile;

            if (cabwiz == null)
            {
                throw new ArgumentNullException("cabwiz", "Missing reference to a CabwizApplication object.");
            }

            var output = project.GetOutput(profile);

            // Create the .INF file for Cabwiz to process.
            var inf = output.CreateCabwizInf(profile);

            // Set the output directory
            cabwiz.DestinationDirectory = project.GetOutputDirectory(profile);

            // add some feedback
            feedback.WriteLine("   > {0}", cabwiz.PreviewCommandLine(inf));

            int exitCode = cabwiz.Run(inf);
            if (exitCode != 0)
            {
                feedback.WriteLine("   {0} returned {1}", System.IO.Path.GetFileName(cabwiz.FileName), exitCode);

                return false;
            }
            else
            {
                return true;
            }
        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the FeedbackTextWriter class using the specified feedback object as the underlying output target, using UTF-8 encoding.
 /// </summary>
 /// <param name="feedback">The feedback object</param>
 public FeedbackTextWriter(IBuildFeedback feedback)
     : this(feedback, Encoding.UTF8)
 {
     // nothing else to do here.
 }
Example #20
0
 /// <summary>
 /// Executes the Build method of the specified task.
 /// </summary>
 /// <param name="task">The build task to execute.</param>
 /// <param name="feedback">The feedback object.</param>
 /// <returns>The value returned by the task's Build method.</returns>
 protected virtual bool BuildTask(IBuildTask task, IBuildFeedback feedback)
 {
     return(task.Build(feedback));
 }