/// <summary> /// Starts to run a build. /// </summary> /// <param name="project">The project/solution to build</param> /// <param name="options">The build options that should be used</param> /// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output. /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine /// will ensure that output from two projects building in parallel isn't interleaved.</param> /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed /// when the build completes.</param> public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink) { if (project == null) { throw new ArgumentNullException("solution"); } if (options == null) { throw new ArgumentNullException("options"); } Solution solution = project.ParentSolution; if (solution == null) { throw new ArgumentException("project.ParentSolution must not be null", "project"); } if (string.IsNullOrEmpty(options.SolutionConfiguration)) { options.SolutionConfiguration = solution.Preferences.ActiveConfiguration; } if (string.IsNullOrEmpty(options.SolutionPlatform)) { options.SolutionPlatform = solution.Preferences.ActivePlatform; } BuildEngine engine = new BuildEngine(options, project); engine.buildStart = DateTime.Now; engine.combinedBuildFeedbackSink = realtimeBuildFeedbackSink; engine.progressMonitor = realtimeBuildFeedbackSink.ProgressMonitor; try { engine.rootNode = engine.CreateBuildGraph(project); } catch (CyclicDependencyException ex) { if (ex.Project1 != null && ex.Project2 != null) { engine.results.Add(new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name)); } else { engine.results.Add(new BuildError(null, "Cyclic dependency")); } engine.results.Result = BuildResultCode.BuildFileError; engine.ReportDone(); return; } engine.workersToStart = options.ParallelProjectCount; if (engine.workersToStart < 1) { engine.workersToStart = 1; } engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled); engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}"); engine.StartBuildProjects(); engine.UpdateProgressTaskName(); }
/// <summary> /// Starts to run a build. /// </summary> /// <param name="project">The project/solution to build</param> /// <param name="options">The build options that should be used</param> /// <param name="buildFeedbackSink">The build feedback sink that receives the build output. /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine /// will ensure that output from two projects building in parallel isn't interleaved.</param> /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed /// when the build completes.</param> public static Task <BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor) { if (project == null) { throw new ArgumentNullException("project"); } if (options == null) { throw new ArgumentNullException("options"); } BuildEngine engine = new BuildEngine(options, project); engine.buildStart = DateTime.Now; engine.combinedBuildFeedbackSink = buildFeedbackSink; engine.progressMonitor = progressMonitor; try { engine.rootNode = engine.CreateBuildGraph(project); } catch (CyclicDependencyException ex) { BuildError error; if (ex.Project1 != null && ex.Project2 != null) { error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name); } else { error = new BuildError(null, "Cyclic dependency"); } engine.results.Add(error); if (engine.combinedBuildFeedbackSink != null) { engine.combinedBuildFeedbackSink.ReportError(error); engine.combinedBuildFeedbackSink.ReportMessage(error.ToRichText()); } engine.results.Result = BuildResultCode.BuildFileError; engine.ReportDone(); return(engine.tcs.Task); } engine.workersToStart = options.ParallelProjectCount; if (engine.workersToStart < 1) { engine.workersToStart = 1; } engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled); engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}"); engine.StartBuildProjects(); engine.UpdateProgressTaskName(); return(engine.tcs.Task); }
/// <summary> /// Starts to run a build. /// </summary> /// <param name="project">The project/solution to build</param> /// <param name="options">The build options that should be used</param> /// <param name="buildFeedbackSink">The build feedback sink that receives the build output. /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine /// will ensure that output from two projects building in parallel isn't interleaved.</param> /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed /// when the build completes.</param> public static Task<BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor) { if (project == null) throw new ArgumentNullException("project"); if (options == null) throw new ArgumentNullException("options"); BuildEngine engine = new BuildEngine(options, project); engine.buildStart = DateTime.Now; engine.combinedBuildFeedbackSink = buildFeedbackSink; engine.progressMonitor = progressMonitor; try { engine.rootNode = engine.CreateBuildGraph(project); } catch (CyclicDependencyException ex) { BuildError error; if (ex.Project1 != null && ex.Project2 != null) error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name); else error = new BuildError(null, "Cyclic dependency"); engine.results.Add(error); if (engine.combinedBuildFeedbackSink != null) { engine.combinedBuildFeedbackSink.ReportError(error); engine.combinedBuildFeedbackSink.ReportMessage(error.ToRichText()); } engine.results.Result = BuildResultCode.BuildFileError; engine.ReportDone(); return engine.tcs.Task; } engine.workersToStart = options.ParallelProjectCount; if (engine.workersToStart < 1) engine.workersToStart = 1; engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled); engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}"); engine.StartBuildProjects(); engine.UpdateProgressTaskName(); return engine.tcs.Task; }
/// <summary> /// Starts to run a build. /// </summary> /// <param name="project">The project/solution to build</param> /// <param name="options">The build options that should be used</param> /// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output. /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine /// will ensure that output from two projects building in parallel isn't interleaved.</param> /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed /// when the build completes.</param> public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink) { if (project == null) throw new ArgumentNullException("solution"); if (options == null) throw new ArgumentNullException("options"); Solution solution = project.ParentSolution; if (solution == null) throw new ArgumentException("project.ParentSolution must not be null", "project"); if (string.IsNullOrEmpty(options.SolutionConfiguration)) options.SolutionConfiguration = solution.Preferences.ActiveConfiguration; if (string.IsNullOrEmpty(options.SolutionPlatform)) options.SolutionPlatform = solution.Preferences.ActivePlatform; BuildEngine engine = new BuildEngine(options, project); engine.buildStart = DateTime.Now; engine.combinedBuildFeedbackSink = realtimeBuildFeedbackSink; engine.progressMonitor = realtimeBuildFeedbackSink.ProgressMonitor; try { engine.rootNode = engine.CreateBuildGraph(project); } catch (CyclicDependencyException ex) { if (ex.Project1 != null && ex.Project2 != null) engine.results.Add(new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name)); else engine.results.Add(new BuildError(null, "Cyclic dependency")); engine.results.Result = BuildResultCode.BuildFileError; engine.ReportDone(); return; } engine.workersToStart = options.ParallelProjectCount; if (engine.workersToStart < 1) engine.workersToStart = 1; engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled); engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}"); engine.StartBuildProjects(); engine.UpdateProgressTaskName(); }