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)); }
/// <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); }
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); }
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(); } } }
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; }
public ILogger CreateLogger(MSBuildEngineWorker engineWorker) { return(new TaskBoundAdditionalLogger(this, engineWorker)); }
public TaskBoundAdditionalLogger(TaskBoundAdditionalLoggerDescriptor desc, MSBuildEngineWorker engineWorker) { this.desc = desc; this.engineWorker = engineWorker; }
/// <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; }
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(); } } }
public ILogger CreateLogger(MSBuildEngineWorker engineWorker) { return new TaskBoundAdditionalLogger(this, engineWorker); }