Esempio n. 1
0
		/// <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.</param>
		public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink, IProgressMonitor progressMonitor)
		{
			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 = 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;
			
			if (progressMonitor != null) {
				progressMonitor.Cancelled += engine.BuildCancelled;
				progressMonitor.BeginTask("", engine.nodeDict.Count, true);
			}
			
			engine.ReportMessageInternal("${res:MainWindow.CompilerMessages.BuildStarted}");
			engine.StartBuildProjects();
			engine.UpdateProgressTaskName();
		}
Esempio n. 2
0
        /// <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.</param>
        public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink, IProgressMonitor progressMonitor)
        {
            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           = 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;
            }

            if (progressMonitor != null)
            {
                progressMonitor.Cancelled += engine.BuildCancelled;
                progressMonitor.BeginTask("", engine.nodeDict.Count, true);
            }

            engine.ReportMessageInternal("${res:MainWindow.CompilerMessages.BuildStarted}");
            engine.StartBuildProjects();
            engine.UpdateProgressTaskName();
        }