/// <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); } } }
/// <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); } }
/// <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); }
/// <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)); }
/// <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; }
/// <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); } } }
/// <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; }
/// <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); }
/// <inheritdoc /> bool IBuildTask.Build(IBuildFeedback feedback) { // this will ALWAYS result in a ArgumentNullException, but we cannot proceed without cabwiz return this.Build(null, feedback); }
/// <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); }
/// <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(); }
/// <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(); }
/// <inheritdoc /> bool IBuildTask.Build(IBuildFeedback feedback) { // this will ALWAYS result in a ArgumentNullException, but we cannot proceed without cabwiz return(this.Build(null, feedback)); }
/// <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. }
/// <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; } }
/// <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)); }