예제 #1
0
        public Task <bool> BuildAsync(IProject project, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, CancellationToken cancellationToken, IEnumerable <string> additionalTargetFiles)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (feedbackSink == null)
            {
                throw new ArgumentNullException("feedbackSink");
            }

            var additionalTargetFileList = additionalTargetFiles != null?additionalTargetFiles.ToList() : new List <string>();

            if (project.MinimumSolutionVersion >= SolutionFormatVersion.VS2010)
            {
                additionalTargetFileList.Add(Path.Combine(Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location), "SharpDevelop.TargetingPack.targets"));
            }
            var engine = new MSBuildEngineWorker(this, project, options, feedbackSink, additionalTargetFileList);

            return(engine.RunBuildAsync(cancellationToken));
        }
예제 #2
0
            /// <summary>
            /// Find available work and run it on the specified worker.
            /// </summary>
            bool RunWorkerInternal(MSBuildEngineWorker worker)
            {
                ProjectToBuild nextFreeProject = null;

                lock (projectsToBuild) {
                    foreach (ProjectToBuild ptb in projectsToBuild)
                    {
                        if (ptb.buildStarted == false && ptb.DependenciesSatisfied())
                        {
                            if (nextFreeProject == null)
                            {
                                nextFreeProject = ptb;

                                // all workers busy, don't look if there is more work available
                                if (workerCount == maxWorkerCount)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                // free workers available + additional work available:
                                // start a new worker
                                LoggingService.Debug("Starting a new worker");
                                workerCount++;
                                Thread thread = new Thread(RunWorkerBuild);
                                thread.Name = "MSBuildEngine worker " + (++lastUniqueWorkerID);
                                thread.SetApartmentState(ApartmentState.STA);
                                thread.Start();

                                // start at most one additional worker, the new worker can
                                // start more threads if desired
                                break;
                            }
                        }
                    }
                    if (nextFreeProject == null)
                    {
                        // nothing to do for this worker thread
                        return(false);
                    }
                    // now build nextFreeProject
                    nextFreeProject.buildStarted = true;
                }                 // end lock

                StatusBarService.SetMessage("${res:MainWindow.CompilerMessages.BuildVerb} " + Path.GetFileNameWithoutExtension(nextFreeProject.file) + "...");

                // run the build:
                if (worker.Build(nextFreeProject))
                {
                    // build successful: mark it as finished
                    lock (projectsToBuild) {
                        nextFreeProject.buildFinished = true;
                    }
                }
                return(true);
            }
예제 #3
0
		public Task<bool> BuildAsync(IProject project, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, CancellationToken cancellationToken, IEnumerable<string> additionalTargetFiles)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			if (feedbackSink == null)
				throw new ArgumentNullException("feedbackSink");
			
			var additionalTargetFileList = additionalTargetFiles != null ? additionalTargetFiles.ToList() : new List<string>();
			if (project.MinimumSolutionVersion >= SolutionFormatVersion.VS2010) {
				additionalTargetFileList.Add(Path.Combine(Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location), "SharpDevelop.TargetingPack.targets"));
			}
			var engine = new MSBuildEngineWorker(this, project, options, feedbackSink, additionalTargetFileList);
			return engine.RunBuildAsync(cancellationToken);
		}
예제 #4
0
            void RunWorkerBuild()
            {
                LoggingService.Debug("Build Worker thread started");
                MSBuildEngineWorker worker = null;

                try {
                    lock (projectsToBuild) {
                        if (unusedWorkers.Count > 0)
                        {
                            worker = unusedWorkers.Dequeue();
                        }
                    }
                    if (worker == null)
                    {
                        worker = new MSBuildEngineWorker(parentEngine, this);
                    }
                    while (RunWorkerInternal(worker))
                    {
                        ;
                    }
                } catch (Exception ex) {
                    MessageService.ShowError(ex);
                } finally {
                    bool wasLastWorker;
                    lock (projectsToBuild) {
                        workerCount--;
                        wasLastWorker = workerCount == 0;
                        if (worker != null)
                        {
                            unusedWorkers.Enqueue(worker);
                        }
                    }
                    LoggingService.Debug("Build Worker thread finished");
                    if (wasLastWorker)
                    {
                        Finish();
                    }
                }
            }
예제 #5
0
			public SharpDevelopLogger(MSBuildEngineWorker engine)
			{
				this.engine = engine;
			}
예제 #6
0
			public EndOfChain(MSBuildEngineWorker engine)
			{
				this.engine = engine;
			}
 public SharpDevelopLogger(MSBuildEngineWorker engine)
 {
     this.engine = engine;
 }
 public EndOfChain(MSBuildEngineWorker engine)
 {
     this.engine = engine;
 }
			public SharpDevelopLogger(MSBuildEngineWorker worker)
			{
				this.worker = worker;
				this.results = worker.buildRun.currentResults;
			}
예제 #10
0
 public ILogger CreateLogger(MSBuildEngineWorker engineWorker)
 {
     return(new TaskBoundAdditionalLogger(this, engineWorker));
 }
예제 #11
0
 public TaskBoundAdditionalLogger(TaskBoundAdditionalLoggerDescriptor desc, MSBuildEngineWorker engineWorker)
 {
     this.desc         = desc;
     this.engineWorker = engineWorker;
 }
예제 #12
0
			/// <summary>
			/// Find available work and run it on the specified worker.
			/// </summary>
			bool RunWorkerInternal(MSBuildEngineWorker worker)
			{
				ProjectToBuild nextFreeProject = null;
				lock (projectsToBuild) {
					foreach (ProjectToBuild ptb in projectsToBuild) {
						if (ptb.buildStarted == false && ptb.DependenciesSatisfied()) {
							if (nextFreeProject == null) {
								nextFreeProject = ptb;
								
								// all workers busy, don't look if there is more work available
								if (workerCount == maxWorkerCount)
									break;
							} else {
								// free workers available + additional work available:
								// start a new worker
								LoggingService.Debug("Starting a new worker");
								workerCount++;
								Thread thread = new Thread(RunWorkerBuild);
								thread.Name = "MSBuildEngine worker " + (++lastUniqueWorkerID);
								thread.SetApartmentState(ApartmentState.STA);
								thread.Start();
								
								// start at most one additional worker, the new worker can
								// start more threads if desired
								break;
							}
						}
					}
					if (nextFreeProject == null) {
						// nothing to do for this worker thread
						return false;
					}
					// now build nextFreeProject
					nextFreeProject.buildStarted = true;
				} // end lock
				
				StatusBarService.SetMessage("${res:MainWindow.CompilerMessages.BuildVerb} " + Path.GetFileNameWithoutExtension(nextFreeProject.file) + "...");
				
				// run the build:
				if (worker.Build(nextFreeProject)) {
					// build successful: mark it as finished
					lock (projectsToBuild) {
						nextFreeProject.buildFinished = true;
					}
				}
				return true;
			}
예제 #13
0
			void RunWorkerBuild()
			{
				LoggingService.Debug("Build Worker thread started");
				MSBuildEngineWorker worker = null;
				try {
					lock (projectsToBuild) {
						if (unusedWorkers.Count > 0)
							worker = unusedWorkers.Dequeue();
					}
					if (worker == null) {
						worker = new MSBuildEngineWorker(parentEngine, this);
					}
					while (RunWorkerInternal(worker));
				} catch (Exception ex) {
					MessageService.ShowError(ex);
				} finally {
					bool wasLastWorker;
					lock (projectsToBuild) {
						workerCount--;
						wasLastWorker = workerCount == 0;
						if (worker != null) {
							unusedWorkers.Enqueue(worker);
						}
					}
					LoggingService.Debug("Build Worker thread finished");
					if (wasLastWorker) {
						Finish();
					}
				}
			}
예제 #14
0
 public SharpDevelopLogger(MSBuildEngineWorker worker)
 {
     this.worker  = worker;
     this.results = worker.buildRun.currentResults;
 }
			public TaskBoundAdditionalLogger(TaskBoundAdditionalLoggerDescriptor desc, MSBuildEngineWorker engineWorker)
			{
				this.desc = desc;
				this.engineWorker = engineWorker;
			}
			public ILogger CreateLogger(MSBuildEngineWorker engineWorker)
			{
				return new TaskBoundAdditionalLogger(this, engineWorker);
			}