示例#1
0
 public void StartBuild(BuildJob job)
 {
     if (job == null)
     {
         throw new ArgumentNullException("job");
     }
     lock (this) {
         if (currentJob != null)
         {
             throw new InvalidOperationException("Already running a job");
         }
         currentJob          = job;
         requestCancellation = false;
     }
                 #if WORKERDEBUG
     Console.Title = "BuildWorker - " + Path.GetFileName(job.ProjectFileName);
                 #endif
     Program.Log("Got job:");
     Program.Log(job.ToString());
     Program.Log("Start build thread");
     Thread thread = new Thread(RunThread);
     thread.Name = "Build thread";
     thread.SetApartmentState(ApartmentState.STA);
     thread.Start();
 }
示例#2
0
 public void StartBuild(BuildJob job)
 {
     // called on communication thread
     if (job == null)
     {
         throw new ArgumentNullException("job");
     }
     Program.Log("Got job:");
     Program.Log(job.ToString());
     lock (this) {
         if (currentJob != null)
         {
             throw new InvalidOperationException("Already running a job");
         }
         currentJob          = job;
         requestCancellation = false;
         Monitor.PulseAll(this);
     }
                 #if WORKERDEBUG
     Console.Title = "BuildWorker - " + Path.GetFileName(job.ProjectFileName);
                 #endif
 }
示例#3
0
		public void StartBuild(BuildJob job)
		{
			// called on communication thread
			if (job == null)
				throw new ArgumentNullException("job");
			Program.Log("Got job:");
			Program.Log(job.ToString());
			lock (this) {
				if (currentJob != null)
					throw new InvalidOperationException("Already running a job");
				currentJob = job;
				requestCancellation = false;
				Monitor.PulseAll(this);
			}
			#if WORKERDEBUG
			Console.Title = "BuildWorker - " + Path.GetFileName(job.ProjectFileName);
			#endif
		}
示例#4
0
		public void StartBuild(BuildJob job)
		{
			if (job == null)
				throw new ArgumentNullException("job");
			lock (this) {
				if (currentJob != null)
					throw new InvalidOperationException("Already running a job");
				currentJob = job;
				requestCancellation = false;
			}
			#if WORKERDEBUG
			Console.Title = "BuildWorker - " + Path.GetFileName(job.ProjectFileName);
			#endif
			Program.Log("Got job:");
			Program.Log(job.ToString());
			Program.Log("Start build thread");
			Thread thread = new Thread(RunThread);
			thread.Name = "Build thread";
			thread.SetApartmentState(ApartmentState.STA);
			thread.Start();
		}
		void StartBuild()
		{
			WorkerManager.ShowError = MessageService.ShowError;
			BuildWorker.BuildSettings settings = new BuildWorker.BuildSettings();
			SharpDevelopLogger logger = new SharpDevelopLogger(this);
			settings.Logger.Add(logger);
			
			InterestingTasks.AddRange(MSBuildEngine.CompileTaskNames);
			foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) {
				settings.Logger.Add(loggerProvider.CreateLogger(this));
			}
			
			BuildJob job = new BuildJob();
			job.IntPtrSize = IntPtr.Size;
			job.ProjectFileName = project.FileName;
			// Never report custom events (those are usually derived EventArgs classes, and SharpDevelop
			// doesn't have the matching assemblies loaded - see SD2-1514).
			// Also, remove the flags for the controllable events.
			job.EventMask = EventTypes.All & ~(ControllableEvents | EventTypes.Custom);
			// Add back active controllable events.
			if (ReportMessageEvents)
				job.EventMask |= EventTypes.Message;
			if (ReportTargetStartedEvents)
				job.EventMask |= EventTypes.TargetStarted;
			if (ReportTargetFinishedEvents)
				job.EventMask |= EventTypes.TargetFinished;
			if (ReportAllTaskStartedEvents)
				job.EventMask |= EventTypes.TaskStarted;
			if (ReportAllTaskFinishedEvents)
				job.EventMask |= EventTypes.TaskFinished;
			if (ReportUnknownEvents)
				job.EventMask |= EventTypes.Unknown;
			
			if (!(ReportAllTaskStartedEvents && ReportAllTaskFinishedEvents)) {
				// just some TaskStarted & TaskFinished events should be reported
				job.InterestingTaskNames.AddRange(InterestingTasks);
			}
			
			job.AdditionalImports.AddRange(additionalTargetFiles);
			
			BuildPropertyGroup pg = new BuildPropertyGroup();
			MSBuildBasedProject.InitializeMSBuildProjectProperties(pg);
			foreach (BuildProperty p in pg) {
				job.Properties[p.Name] = p.FinalValue;
			}
			
			Solution solution = project.ParentSolution;
			job.Properties["SolutionDir"] = EnsureBackslash(solution.Directory);
			job.Properties["SolutionExt"] = ".sln";
			job.Properties["SolutionFileName"] = Path.GetFileName(solution.FileName);
			job.Properties["SolutionPath"] = solution.FileName;
			
			foreach (var pair in options.Properties) {
				job.Properties[pair.Key] = pair.Value;
			}
			job.Properties["Configuration"] = options.Configuration;
			if (options.Platform == "Any CPU")
				job.Properties["Platform"] = "AnyCPU";
			else
				job.Properties["Platform"] = options.Platform;
			job.Target = options.Target.TargetName;
			
			bool buildInProcess = false;
			if (AllowBuildInProcess && Interlocked.CompareExchange(ref isBuildingInProcess, 1, 0) == 0) {
				buildInProcess = true;
			}
			
			//HACK: Build .net 4.0 projects in process
			if (SDLite.BuildHelper.IsProject40(File.ReadAllText(project.FileName))) {
				buildInProcess = true;
				Interlocked.Exchange(ref isBuildingInProcess, 1);
			}			
						
			LoggingService.Info("Start job (buildInProcess=" + buildInProcess + "): " + job.ToString());
			
			if (buildInProcess) {
				settings.BuildDoneCallback = delegate(bool success) {
					LoggingService.Debug("BuildInProcess: Received BuildDoneCallback");
					if (Interlocked.Exchange(ref isBuildingInProcess, 0) != 1) {
					    //HACK: It takes no sense.
						//MessageService.ShowError("isBuildingInProcess should have been 1!");
					}
					logger.FlushCurrentError();
					feedbackSink.Done(success);
				};
				
				Thread thread = new Thread(new ThreadStart(
					delegate {
						LoggingService.Debug("Acquiring InProcessMSBuildLock");
						lock (MSBuildInternals.InProcessMSBuildLock) {
							WorkerManager.RunBuildInProcess(job, settings);
							LoggingService.Debug("Leaving InProcessMSBuildLock");
						}
					}));
				thread.Name = "InProcess build thread " + thread.ManagedThreadId;
				thread.SetApartmentState(ApartmentState.STA);
				thread.Start();
			} else {
				settings.BuildDoneCallback = delegate(bool success) {
					LoggingService.Debug("BuildOutOfProcess: Received BuildDoneCallback");
					logger.FlushCurrentError();
					feedbackSink.Done(success);
				};
				
				WorkerManager.StartBuild(job, settings);
			}
		}