Example #1
0
        void RunThread()
        {
            Program.Log("In build thread");
            bool success = false;

            try {
                if (File.Exists(currentJob.ProjectFileName))
                {
                    success = buildWrapper.DoBuild(currentJob, new ForwardingLogger(this));
                }
                else
                {
                    success = false;
                    HostReportEvent(new BuildErrorEventArgs(null, null, currentJob.ProjectFileName, 0, 0, 0, 0, "Project file '" + Path.GetFileName(currentJob.ProjectFileName) + "' not found", null, null));
                }
            } catch (Exception ex) {
                host.Writer.Write("ReportException");
                host.Writer.Write(ex.ToString());
            } finally {
                Program.Log("BuildDone");

                                #if WORKERDEBUG
                Console.Title = "BuildWorker - no job";
                DisplayEventCounts();
                                #endif

                lock (this) {
                    currentJob = null;
                }
                // in the moment we call BuildDone, we can get the next job
                host.Writer.Write("BuildDone");
                host.Writer.Write(success);
            }
        }
Example #2
0
        public static void StartBuild(BuildJob job, BuildSettings settings)
        {
            if (job == null)
            {
                throw new ArgumentNullException("job");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            BuildRun buildRun = new BuildRun(job, settings);

            lock (lockObject) {
                if (freeWorkerProcesses.Count > 0)
                {
                    DequeueFreeWorkerProcess().StartBuild(buildRun);
                }
                else
                {
                    outstandingBuildRuns.Enqueue(buildRun);
                    if (workerProcessCount < MaxWorkerProcessCount)
                    {
                        workerProcessCount++;
                        (new WorkerProcessHost()).Start();
                    }
                }
            }
        }
Example #3
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();
 }
Example #4
0
 public BuildRun(BuildJob job, BuildSettings settings)
 {
     this.job      = job;
     this.settings = settings;
     foreach (ILogger logger in settings.Logger)
     {
         logger.Initialize(eventSource);
     }
 }
		public void RunBuildJob(BuildJob job, IMSBuildChainedLoggerFilter loggerChain, Action<bool> reportWhenDone, CancellationToken cancellationToken)
		{
			if (job == null)
				throw new ArgumentNullException("job");
			if (loggerChain == null)
				throw new ArgumentNullException("loggerChain");
			BuildWorker worker = GetFreeWorker();
			worker.RunJob(job, loggerChain, reportWhenDone, cancellationToken);
		}
		public static void RunBuildInProcess(BuildJob job, BuildSettings settings)
		{
			if (job == null)
				throw new ArgumentNullException("job");
			if (settings == null)
				throw new ArgumentNullException("settings");
			lock (lockObject) {
				if (inProcessBuildWorker == null)
					inProcessBuildWorker = new Program();
			}
			inProcessBuildWorker.BuildInProcess(settings, job);
		}
Example #7
0
        public bool DoBuild(BuildJob job, ILogger logger)
        {
            BuildParameters parameters = new BuildParameters();
            parameters.MaxNodeCount = 1;
            parameters.Loggers = new ILogger[] { logger };

            Program.Log("Building target '" + job.Target + "' in " + job.ProjectFileName);
            string[] targets = job.Target.Split(';');
            BuildRequestData request = new BuildRequestData(job.ProjectFileName, job.Properties, null, targets, null);

            BuildResult result = BuildManager.DefaultBuildManager.Build(parameters, request);
            return result.OverallResult == BuildResultCode.Success;
        }
Example #8
0
        public bool DoBuild(BuildJob job, ILogger logger)
        {
            BuildParameters parameters = new BuildParameters();

            parameters.MaxNodeCount = 1;
            parameters.Loggers      = new ILogger[] { logger };

            Program.Log("Building target '" + job.Target + "' in " + job.ProjectFileName);
            string[]         targets = job.Target.Split(';');
            BuildRequestData request = new BuildRequestData(job.ProjectFileName, job.Properties, null, targets, null);

            BuildResult result = BuildManager.DefaultBuildManager.Build(parameters, request);

            return(result.OverallResult == BuildResultCode.Success);
        }
			public void RunJob(BuildJob job, IMSBuildChainedLoggerFilter loggerChain, Action<bool> reportWhenDone, CancellationToken cancellationToken)
			{
				Debug.Assert(loggerChain != null);
				this.loggerChain = loggerChain;
				this.reportWhenDone = reportWhenDone;
				try {
					process.Writer.Write("StartBuild");
					job.WriteTo(process.Writer);
					this.cancellationRegistration = cancellationToken.Register(OnCancel);
				} catch (IOException ex) {
					// "Pipe is broken"
					loggerChain.HandleError(new BuildError(null, 0, 0, null, "Error talking to build worker: " + ex.Message));
					BuildDone(false);
				}
			}
Example #10
0
		public static BuildJob ReadFrom(BinaryReader reader)
		{
			BuildJob job = new BuildJob();
			job.ProjectFileName = reader.ReadString();
			job.Target = reader.ReadString();
			job.EventMask = (EventTypes)reader.ReadInt32();
			int c = reader.ReadInt32();
			for (int i = 0; i < c; i++) {
				job.properties.Add(reader.ReadString(), reader.ReadString());
			}
			c = reader.ReadInt32();
			for (int i = 0; i < c; i++) {
				job.interestingTaskNames.Add(reader.ReadString());
			}
			return job;
		}
Example #11
0
        void DataReceived(string command, BinaryReader reader)
        {
            switch (command)
            {
            case "StartBuild":
                StartBuild(BuildJob.ReadFrom(reader));
                break;

            case "Cancel":
                CancelBuild();
                break;

            default:
                throw new InvalidOperationException("Unknown command");
            }
        }
Example #12
0
 public static void RunBuildInProcess(BuildJob job, BuildSettings settings)
 {
     if (job == null)
     {
         throw new ArgumentNullException("job");
     }
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     lock (lockObject) {
         if (inProcessBuildWorker == null)
         {
             inProcessBuildWorker = new Program();
         }
     }
     inProcessBuildWorker.BuildInProcess(settings, job);
 }
Example #13
0
		public bool DoBuild(BuildJob job, ILogger logger)
		{
			engine.RegisterLogger(logger);
			
			Program.Log("Building target '" + job.Target + "' in " + job.ProjectFileName);
			string[] targets = job.Target.Split(';');
			
			BuildPropertyGroup globalProperties = new BuildPropertyGroup();
			foreach (var pair in job.Properties) {
				globalProperties.SetProperty(pair.Key, pair.Value, true);
			}
			
			try {
				return engine.BuildProjectFile(job.ProjectFileName, targets, globalProperties);
			} finally {
				engine.UnregisterAllLoggers();
			}
		}
		public static void StartBuild(BuildJob job, BuildSettings settings)
		{
			if (job == null)
				throw new ArgumentNullException("job");
			if (settings == null)
				throw new ArgumentNullException("settings");
			
			BuildRun buildRun = new BuildRun(job, settings);
			lock (lockObject) {
				if (freeWorkerProcesses.Count > 0) {
					DequeueFreeWorkerProcess().StartBuild(buildRun);
				} else {
					outstandingBuildRuns.Enqueue(buildRun);
					if (workerProcessCount < MaxWorkerProcessCount) {
						workerProcessCount++;
						(new WorkerProcessHost()).Start();
					}
				}
			}
		}
        public bool DoBuild(BuildJob job, ILogger logger)
        {
            engine.RegisterLogger(logger);

            Program.Log("Building target '" + job.Target + "' in " + job.ProjectFileName);
            string[] targets = job.Target.Split(';');

            BuildPropertyGroup globalProperties = new BuildPropertyGroup();

            foreach (var pair in job.Properties)
            {
                globalProperties.SetProperty(pair.Key, pair.Value, true);
            }

            try {
                return(engine.BuildProjectFile(job.ProjectFileName, targets, globalProperties));
            } finally {
                engine.UnregisterAllLoggers();
            }
        }
Example #16
0
        public static BuildJob ReadFrom(BinaryReader reader)
        {
            BuildJob job = new BuildJob();

            job.ProjectFileName = reader.ReadString();
            job.Target          = reader.ReadString();
            job.EventMask       = (EventTypes)reader.ReadInt32();
            int c = reader.ReadInt32();

            for (int i = 0; i < c; i++)
            {
                job.properties.Add(reader.ReadString(), reader.ReadString());
            }
            c = reader.ReadInt32();
            for (int i = 0; i < c; i++)
            {
                job.interestingTaskNames.Add(reader.ReadString());
            }
            return(job);
        }
Example #17
0
        internal void BuildInProcess(BuildSettings settings, BuildJob job)
        {
            lock (this) {
                if (currentJob != null)
                {
                    throw new InvalidOperationException("Already running a job");
                }
                currentJob          = job;
                requestCancellation = false;
                hostEventSource     = new EventSource();
            }
            job.CancelCallback = delegate {
                lock (this) {
                    if (currentJob == job)
                    {
                        requestCancellation = true;
                    }
                }
            };
            bool success = false;

            try {
                foreach (ILogger logger in settings.Logger)
                {
                    logger.Initialize(hostEventSource);
                }
                success = DoBuild();
                foreach (ILogger logger in settings.Logger)
                {
                    logger.Shutdown();
                }
            } finally {
                lock (this) {
                    currentJob = null;
                }
                if (settings.BuildDoneCallback != null)
                {
                    settings.BuildDoneCallback(success);
                }
            }
        }
Example #18
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
 }
Example #19
0
        void RunThread()
        {
            Program.Log("In build thread");
            bool success = false;

            try {
                success = DoBuild();
            } catch (Exception ex) {
                host.CallMethodOnHost("ReportException", ex.ToString());
            } finally {
                Program.Log("BuildDone");

                #if WORKERDEBUG
                Console.Title = "BuildWorker - no job";
                DisplayEventCounts();
                #endif

                lock (this) {
                    currentJob = null;
                }
                // in the moment we call BuildDone, we can get the next job
                host.CallMethodOnHost("BuildDone", success);
            }
        }
			public BuildRun(BuildJob job, BuildSettings settings)
			{
				this.job = job;
				this.settings = settings;
				foreach (ILogger logger in settings.Logger) {
					logger.Initialize(eventSource);
				}
			}
		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);
			}
		}
Example #22
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
		}
Example #23
0
 void RunThread()
 {
     Program.Log("In build thread");
     bool success = false;
     try {
         success = DoBuild();
     } catch (Exception ex) {
         host.CallMethodOnHost("ReportException", ex.ToString());
     } finally {
         Program.Log("BuildDone");
         
         #if WORKERDEBUG
         Console.Title = "BuildWorker - no job";
         DisplayEventCounts();
         #endif
         
         lock (this) {
             currentJob = null;
         }
         // in the moment we call BuildDone, we can get the next job
         host.CallMethodOnHost("BuildDone", success);
     }
 }
Example #24
0
		void StartBuild()
		{
			Dictionary<string, string> globalProperties = new Dictionary<string, string>();
			MSBuildBasedProject.InitializeMSBuildProjectProperties(globalProperties);
			
			foreach (KeyValuePair<string, string> pair in options.Properties) {
				LoggingService.Debug("Setting property " + pair.Key + " to '" + pair.Value + "'");
				globalProperties[pair.Key] = pair.Value;
			}
			globalProperties["Configuration"] = options.Configuration;
			if (options.Platform == "Any CPU")
				globalProperties["Platform"] = "AnyCPU";
			else
				globalProperties["Platform"] = options.Platform;
			
			InterestingTasks.AddRange(MSBuildEngine.CompileTaskNames);
			
			loggers.Add(new SharpDevelopLogger(this));
			if (options.BuildOutputVerbosity == BuildOutputVerbosity.Diagnostic) {
				this.ReportMessageEvents = true;
				this.ReportAllTaskFinishedEvents = true;
				this.ReportAllTaskStartedEvents = true;
				this.ReportTargetFinishedEvents = true;
				this.ReportTargetStartedEvents = true;
				this.ReportUnknownEvents = true;
				loggers.Add(new SDConsoleLogger(feedbackSink, LoggerVerbosity.Diagnostic));
				globalProperties["MSBuildTargetsVerbose"] = "true";
			}
			//loggers.Add(new BuildLogFileLogger(project.FileName + ".log", LoggerVerbosity.Diagnostic));
			foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) {
				loggers.Add(loggerProvider.CreateLogger(this));
			}
			
			loggerChain = new EndOfChain(this);
			foreach (IMSBuildLoggerFilter loggerFilter in MSBuildEngine.MSBuildLoggerFilters) {
				loggerChain = loggerFilter.CreateFilter(this, loggerChain) ?? loggerChain;
			}
			
			WriteAdditionalTargetsToTempFile(globalProperties);
			
			BuildJob job = new BuildJob();
			job.ProjectFileName = projectFileName;
			job.Target = options.Target.TargetName;
			
			// First remove the flags for the controllable events.
			job.EventMask = EventTypes.All & ~ControllableEvents;
			// 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);
			}
			foreach (var pair in globalProperties) {
				job.Properties.Add(pair.Key, pair.Value);
			}
			
			foreach (ILogger logger in loggers) {
				logger.Initialize(eventSource);
			}
			
			if (projectMinimumSolutionVersion <= Solution.SolutionVersionVS2008) {
				if (DotnetDetection.IsDotnet35SP1Installed()) {
					BuildWorkerManager.MSBuild35.RunBuildJob(job, loggerChain, OnDone, feedbackSink.ProgressMonitor.CancellationToken);
				} else {
					loggerChain.HandleError(new BuildError(job.ProjectFileName, ".NET 3.5 SP1 is required to build this project."));
					OnDone(false);
				}
			} else {
				BuildWorkerManager.MSBuild40.RunBuildJob(job, loggerChain, OnDone, feedbackSink.ProgressMonitor.CancellationToken);
			}
		}
Example #25
0
 internal void BuildInProcess(BuildSettings settings, BuildJob job)
 {
     lock (this) {
         if (currentJob != null)
             throw new InvalidOperationException("Already running a job");
         currentJob = job;
         requestCancellation = false;
         hostEventSource = new EventSource();
     }
     job.CancelCallback = delegate {
         lock (this) {
             if (currentJob == job) {
                 requestCancellation = true;
             }
         }
     };
     bool success = false;
     try {
         foreach (ILogger logger in settings.Logger) {
             logger.Initialize(hostEventSource);
         }
         success = DoBuild();
         foreach (ILogger logger in settings.Logger) {
             logger.Shutdown();
         }
     } finally {
         lock (this) {
             currentJob = null;
         }
         if (settings.BuildDoneCallback != null)
             settings.BuildDoneCallback(success);
     }
 }
Example #26
0
		void RunThread()
		{
			Program.Log("In build thread");
			bool success = false;
			try {
				success = buildWrapper.DoBuild(currentJob, new ForwardingLogger(this));
			} catch (Exception ex) {
				host.Writer.Write("ReportException");
				host.Writer.Write(ex.ToString());
			} finally {
				Program.Log("BuildDone");
				
				#if WORKERDEBUG
				Console.Title = "BuildWorker - no job";
				DisplayEventCounts();
				#endif
				
				lock (this) {
					currentJob = null;
				}
				// in the moment we call BuildDone, we can get the next job
				host.Writer.Write("BuildDone");
				host.Writer.Write(success);
			}
		}
Example #27
0
		public bool BuildProject(Project project, BuildJob job)
		{
			string buildResultDirectory = "Temp";
			
			if(!Directory.Exists(buildResultDirectory))
				Directory.CreateDirectory(buildResultDirectory);
			
			// Generate build result file name from project path
			char[] chars = Path.GetInvalidFileNameChars();
			string buildResultFile = project.FullFileName;
			
			foreach(var ch in chars)
				buildResultFile = buildResultFile.Replace(ch, '_');
			
			buildResultFile = Path.Combine(buildResultDirectory,  Path.ChangeExtension(buildResultFile, ".tmp"));
			
			string msBuild = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe");
			string binDirectory = AppDomain.CurrentDomain.BaseDirectory;
			
			if(!File.Exists(msBuild))
			{
				MessageService.ShowError(".Net Framework 4.0 not installed.");
				return false;
			}
			
			Environment.SetEnvironmentVariable("BooBinPath", Path.Combine(binDirectory, @"..\AddIns\AddIns\BackendBindings\BooBinding\v4.0"));
			
			// Start msbuild
			ProcessStartInfo info = new ProcessStartInfo()
			{
				FileName = msBuild,
				//Arguments = string.Format(@"/c {0} ""{1}"" /clp:ErrorsOnly;WarningsOnly /nologo", msBuild, project.FullFileName),
				Arguments = string.Format(@"""{1}"" /logger:XmlLogger,""{2}\MSBuildLoggers40.dll"";logfile=""{3}"" /t:{4} /p:{5} /verbosity:m",
				                          null,	// Reserved for testing in "cmd /c"
				                          project.FullFileName,
				                          Path.Combine(binDirectory, "Tools\\Frameworks"),
				                          buildResultFile,
				                          job.Target,
				                          "Configuration=" + job.Properties["Configuration"] + ";" +
				                          "Platform=" + job.Properties["Platform"]),
				UseShellExecute = false,
				RedirectStandardOutput = true,
				CreateNoWindow = true
			};
			
			File.WriteAllText(Path.Combine(buildResultDirectory, "log.tmp"), info.FileName + " " + info.Arguments);
			
			Process process = Process.Start(info);
			process.WaitForExit();
			
			bool succeeded = process.ExitCode == 0;

			try
			{
				// Parse build result
				XmlDocument document = new XmlDocument();
				document.Load(buildResultFile);

				XmlNodeList projects = document.SelectNodes("/build/project");

				foreach(XmlNode p in projects)
				{
					string projectFile = p.Attributes["file"].Value;

					ReportResult(projectFile, p.SelectNodes("error"), ReportError);
					ReportResult(projectFile, p.SelectNodes("warning"), ReportWarning);
					ReportResult(projectFile, p.SelectNodes("message"), ReportMessage);
				}
			}
			catch(Exception ex)
			{
				LoggingService.Error("Parse build result failed.", ex);
				succeeded = false;
			}
			
			if(!succeeded)
				LoggingService.Info(process.StandardOutput.ReadToEnd());
			
			return succeeded;
		}
Example #28
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();
		}
Example #29
0
		void RunThread()
		{
			Program.Log("In build thread");
			bool success = false;
			try {
				if (File.Exists(currentJob.ProjectFileName)) {
					success = buildWrapper.DoBuild(currentJob, new ForwardingLogger(this));
				} else {
					success = false;
					HostReportEvent(new BuildErrorEventArgs(null, null, currentJob.ProjectFileName, 0, 0, 0, 0, "Project file '" + Path.GetFileName(currentJob.ProjectFileName) + "' not found", null, null));
				}
			} catch (Exception ex) {
				host.Writer.Write("ReportException");
				host.Writer.Write(ex.ToString());
			} finally {
				Program.Log("BuildDone");
				
				#if WORKERDEBUG
				Console.Title = "BuildWorker - no job";
				DisplayEventCounts();
				#endif
				
				lock (this) {
					currentJob = null;
				}
				// in the moment we call BuildDone, we can get the next job
				host.Writer.Write("BuildDone");
				host.Writer.Write(success);
			}
		}