コード例 #1
0
		internal MSBuildEngineWorker(MSBuildEngine parentEngine, MSBuildEngine.BuildRun buildRun)
		{
			this.parentEngine = parentEngine;
			this.buildRun = buildRun;
			engine = buildRun.CreateEngine();
			
			logger = new SharpDevelopLogger(this);
			engine.RegisterLogger(logger);
			foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) {
				engine.RegisterLogger(loggerProvider.CreateLogger(this));
			}
		}
コード例 #2
0
        internal MSBuildEngineWorker(MSBuildEngine parentEngine, MSBuildEngine.BuildRun buildRun)
        {
            this.parentEngine = parentEngine;
            this.buildRun     = buildRun;
            engine            = buildRun.CreateEngine();

            logger = new SharpDevelopLogger(this);
            engine.RegisterLogger(logger);
            foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers)
            {
                engine.RegisterLogger(loggerProvider.CreateLogger(this));
            }
        }
コード例 #3
0
        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;
            }
            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)
                    {
                        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);
            }
        }
コード例 #4
0
		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);
			}
		}