/// <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 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> /// 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 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); }