Exemple #1
1
		/// <summary>
		/// Starts to run a build inside the SharpDevelop GUI.
		/// Only one build can run inside the GUI at one time.
		/// </summary>
		/// <param name="project">The project/solution to build.</param>
		/// <param name="options">The build options.</param>
		public static void BuildInGui(IBuildable project, BuildOptions options)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			WorkbenchSingleton.AssertMainThread();
			if (guiBuildCancellation != null) {
				BuildResults results = new BuildResults();
				WorkbenchSingleton.StatusBar.SetMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
				BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
				results.Add(error);
				TaskService.Add(new Task(error));
				results.Result = BuildResultCode.MSBuildAlreadyRunning;
				if (options.Callback != null) {
					options.Callback(results);
				}
			} else {
				guiBuildCancellation = new CancellationTokenSource();
				IProgressMonitor progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token);
				guiBuildTrackedFeature = AnalyticsMonitorService.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build");
				WorkbenchSingleton.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}..."));
				ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options));
				StartBuild(project, options,
				           new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor, WorkbenchSingleton.StatusBar));
			}
		}
Exemple #2
0
 /// <summary>
 /// Starts to run a build inside the SharpDevelop GUI.
 /// Only one build can run inside the GUI at one time.
 /// </summary>
 /// <param name="project">The project/solution to build.</param>
 /// <param name="options">The build options.</param>
 public static void BuildInGui(IBuildable project, BuildOptions options)
 {
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     WorkbenchSingleton.AssertMainThread();
     if (guiBuildCancellation != null)
     {
         BuildResults results = new BuildResults();
         WorkbenchSingleton.StatusBar.SetMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
         BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
         results.Add(error);
         TaskService.Add(new Task(error));
         results.Result = BuildResultCode.MSBuildAlreadyRunning;
         if (options.Callback != null)
         {
             options.Callback(results);
         }
     }
     else
     {
         guiBuildCancellation = new CancellationTokenSource();
         IProgressMonitor progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token);
         guiBuildTrackedFeature = AnalyticsMonitorService.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build");
         WorkbenchSingleton.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}..."));
         ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options));
         StartBuild(project, options,
                    new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor, WorkbenchSingleton.StatusBar));
     }
 }
Exemple #3
0
 /// <summary>
 /// Starts to run a build inside the SharpDevelop GUI.
 /// Only one build can run inside the GUI at one time.
 /// </summary>
 /// <param name="project">The project/solution to build.</param>
 /// <param name="options">The build options.</param>
 public static void BuildInGui(IBuildable project, BuildOptions options)
 {
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     WorkbenchSingleton.AssertMainThread();
     if (guiBuildProgressMonitor != null)
     {
         BuildResults results = new BuildResults();
         results.Add(new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
         results.Result = BuildResultCode.MSBuildAlreadyRunning;
         if (options.Callback != null)
         {
             options.Callback(results);
         }
     }
     else
     {
         guiBuildProgressMonitor = new CancellableProgressMonitor(StatusBarService.CreateProgressMonitor());
         Gui.WorkbenchSingleton.Workbench.GetPad(typeof(Gui.CompilerMessageView)).BringPadToFront();
         GuiBuildStarted.RaiseEvent(null, new BuildEventArgs(project, options));
         StartBuild(project, options,
                    new MessageViewSink(TaskService.BuildMessageViewCategory),
                    guiBuildProgressMonitor);
     }
 }
Exemple #4
0
 public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(
         delegate {
         guiBuildProgressMonitor = null;
         GuiBuildFinished.RaiseEvent(null, new BuildEventArgs(buildable, options, results));
     });
 }
		void UpdateLastBuildInfo(BuildResults buildResults)
		{
			if (buildResults.ErrorCount > 0) {
				lastBuildInfo = 1;
			} else {
				lastBuildInfo = 0;
			}
		}
 public BuildEventArgs(IReadOnlyList<IProject> projects, BuildOptions options, BuildResults results)
 {
     if (projects == null)
         throw new ArgumentNullException("projects");
     if (options == null)
         throw new ArgumentNullException("options");
     this.Projects = projects;
     this.Options = options;
     this.Results = results;
 }
 public void Build(IProject project)
 {
     var build = new BuildProject(project);
     build.BuildComplete += BuildComplete;
     buildCompleteEvent.Reset();
     SD.MainThread.InvokeAsyncAndForget(() => build.Run());
     if (buildCompleteEvent.WaitOne(DefaultBuildTimeout)) {
         BuildResults = build.LastBuildResults;
     } else {
         BuildResults = GetBuildTimeoutResult();
     }
     build.BuildComplete -= BuildComplete;
 }
		public void Build(IProject project)
		{
			var build = new BuildProject(project);
			build.BuildComplete += BuildComplete;
			buildCompleteEvent.Reset();
			WorkbenchSingleton.SafeThreadAsyncCall(() => build.Run());
			if (buildCompleteEvent.WaitOne(DefaultBuildTimeout)) {
				BuildResults = build.LastBuildResults;
			} else {
				BuildResults = GetBuildTimeoutResult();
			}
			build.BuildComplete -= BuildComplete;
		}
 public BuildEventArgs(IReadOnlyList <IProject> projects, BuildOptions options, BuildResults results)
 {
     if (projects == null)
     {
         throw new ArgumentNullException("projects");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     this.Projects = projects;
     this.Options  = options;
     this.Results  = results;
 }
 public BuildEventArgs(IBuildable buildable, BuildOptions options, BuildResults results)
 {
     if (buildable == null)
     {
         throw new ArgumentNullException("buildable");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     this.Buildable = buildable;
     this.Options   = options;
     this.Results   = results;
 }
Exemple #11
0
 public void Run(Solution solution, IProject project, BuildOptions options)
 {
     if (isRunning)
     {
         BuildResults results = new BuildResults();
         results.Result = BuildResultCode.MSBuildAlreadyRunning;
         results.Add(new BuildError(null, ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
         if (options.Callback != null)
         {
             options.Callback(results);
         }
     }
     else
     {
         isRunning = true;
         Thread thread = new Thread(new BuildRun(solution, project, options, this).RunMainBuild);
         thread.Name = "MSBuildEngine main worker";
         thread.SetApartmentState(ApartmentState.STA);
         thread.Start();
     }
 }
Exemple #12
0
            public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
            {
                WorkbenchSingleton.SafeThreadAsyncCall(
                    delegate {
                    guiBuildCancellation = null;
                    if (guiBuildTrackedFeature != null)
                    {
                        guiBuildTrackedFeature.EndTracking();
                        guiBuildTrackedFeature = null;
                    }
                    string message;
                    if (results.Result == BuildResultCode.Cancelled)
                    {
                        message = "${res:MainWindow.CompilerMessages.BuildCancelled}";
                    }
                    else
                    {
                        if (results.Result == BuildResultCode.Success)
                        {
                            message = "${res:MainWindow.CompilerMessages.BuildFinished}";
                        }
                        else
                        {
                            message = "${res:MainWindow.CompilerMessages.BuildFailed}";
                        }

                        if (results.ErrorCount > 0)
                        {
                            message += " " + results.ErrorCount + " error(s)";
                        }
                        if (results.WarningCount > 0)
                        {
                            message += " " + results.WarningCount + " warning(s)";
                        }
                    }
                    statusBarService.SetMessage(message);
                    ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results));
                });
            }
		/// <summary>
		/// Starts to run a build inside the SharpDevelop GUI.
		/// Only one build can run inside the GUI at one time.
		/// </summary>
		/// <param name="project">The project/solution to build.</param>
		/// <param name="options">The build options.</param>
		public static void BuildInGui(IBuildable project, BuildOptions options)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			WorkbenchSingleton.AssertMainThread();
			if (guiBuildProgressMonitor != null) {
				BuildResults results = new BuildResults();
				results.Add(new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
				results.Result = BuildResultCode.MSBuildAlreadyRunning;
				if (options.Callback != null) {
					options.Callback(results);
				}
			} else {
				guiBuildProgressMonitor = new CancellableProgressMonitor(StatusBarService.CreateProgressMonitor());
				Gui.WorkbenchSingleton.Workbench.GetPad(typeof(Gui.CompilerMessageView)).BringPadToFront();
				GuiBuildStarted.RaiseEvent(null, new BuildEventArgs(project, options));
				StartBuild(project, options,
				           new MessageViewSink(TaskService.BuildMessageViewCategory),
				           guiBuildProgressMonitor);
			}
		}
		/// <summary>
		/// Runs the test for the project after a successful build.
		/// </summary>
		void OnBuildComplete(BuildResults results, SelectedTests selectedTests)
		{
			if (BuildHasNoErrorsAndStillRunningTests(results)) {
				RunTests(selectedTests);
			} else {
				if (IsRunningTest) {
					Stop();
				}
				ShowErrorList();
			}
		}
 BuildResults GetBuildTimeoutResult()
 {
     var results = new BuildResults { Result = BuildResultCode.Error };
     results.Add(new BuildError(String.Empty, "Timed out waiting for build to complete."));
     return results;
 }
		/// <summary>
		/// Runs the test for the project after a successful build.
		/// </summary>
		void OnBuildComplete(BuildResults results, IProject project, string namespaceFilter, IClass fixture, IMember test)
		{
			if (results.ErrorCount == 0 && IsRunningTest) {
				UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
				
				UnitTestingOptions options = new UnitTestingOptions();
				helper.NoThread = options.NoThread;
				helper.NoLogo = options.NoLogo;
				helper.NoDots = options.NoDots;
				helper.Labels = options.Labels;
				helper.ShadowCopy = !options.NoShadow;
				
				if (options.CreateXmlOutputFile) {
					helper.XmlOutputFile = Path.Combine(Path.GetDirectoryName(project.OutputAssemblyFullPath), project.AssemblyName + "-TestResult.xml");
				}
				
				helper.Initialize(project, namespaceFilter, fixture, test);
				helper.Results = Path.GetTempFileName();
				
				ResetTestResults(project);

				testResultsMonitor.FileName = helper.Results;
				testResultsMonitor.Start();
				
				try {
					RunTests(helper);
				} catch {
					StopMonitoring();
					throw;
				}
			} else {
				if (IsRunningTest) {
					Stop();
				}
				if (TaskService.SomethingWentWrong && ErrorListPad.ShowAfterBuild) {
					ShowErrorList();
				}
			}
		}
 public BuildEventArgs(BuildResults results)
 {
     // TODO: remove this constructor in 4.0
     this.Results = results;
 }
 public FakeProjectBuilder()
 {
     BuildResults = new BuildResults();
 }
        public async Task <BuildResults> BuildAsync(IEnumerable <IProject> projects, BuildOptions options)
        {
            if (projects == null)
            {
                throw new ArgumentNullException("projects");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            SD.MainThread.VerifyAccess();
            if (guiBuildCancellation != null)
            {
                BuildResults results = new BuildResults();
                SD.StatusBar.SetMessage(ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
                BuildError error = new BuildError(null, ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
                results.Add(error);
                TaskService.Add(new SDTask(error));
                results.Result = BuildResultCode.MSBuildAlreadyRunning;
                return(results);
            }
            var projectsList = projects.ToList();

            guiBuildCancellation = new CancellationTokenSource();
            try {
                using (var progressMonitor = SD.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token)) {
                    if (BuildStarted != null)
                    {
                        BuildStarted(this, new BuildEventArgs(projectsList, options));
                    }

                    var trackedFeature = SD.AnalyticsMonitor.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build");
                    SD.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}..."));
                    IBuildable buildable;
                    if (projectsList.Count == 1)
                    {
                        buildable = projectsList[0];
                    }
                    else
                    {
                        buildable = new MultipleProjectBuildable(projectsList);
                    }

                    buildable = buildModifiedProjectsOnly.WrapBuildable(buildable, options.BuildDetection);

                    var sink = new UIBuildFeedbackSink(SD.OutputPad.BuildCategory, SD.StatusBar);
                    // Actually run the build:
                    var results = await BuildEngine.BuildAsync(buildable, options, sink, progressMonitor);

                    string message;
                    if (results.Result == BuildResultCode.Cancelled)
                    {
                        message = "${res:MainWindow.CompilerMessages.BuildCancelled}";
                    }
                    else
                    {
                        if (results.Result == BuildResultCode.Success)
                        {
                            message = "${res:MainWindow.CompilerMessages.BuildFinished}";
                        }
                        else
                        {
                            message = "${res:MainWindow.CompilerMessages.BuildFailed}";
                        }

                        if (results.ErrorCount > 0)
                        {
                            message += " " + results.ErrorCount + " error(s)";
                        }
                        if (results.WarningCount > 0)
                        {
                            message += " " + results.WarningCount + " warning(s)";
                        }
                    }
                    SD.StatusBar.SetMessage(message);
                    trackedFeature.EndTracking();
                    if (BuildFinished != null)
                    {
                        BuildFinished(this, new BuildEventArgs(projectsList, options, results));
                    }

                    return(results);
                }
            } finally {
                guiBuildCancellation = null;
            }
        }
			public SharpDevelopLogger(MSBuildEngineWorker worker)
			{
				this.worker = worker;
				this.results = worker.buildRun.currentResults;
			}
		public BuildEventArgs(BuildResults results)
		{
			// TODO: remove this constructor in 4.0
			this.Results = results;
		}
		public override void Run()
		{
			runMethodCalled = true;
			LastBuildResults = new BuildResults();
		}
		public void Run(Solution solution, IProject project, BuildOptions options)
		{
			if (isRunning) {
				BuildResults results = new BuildResults();
				results.Result = BuildResultCode.MSBuildAlreadyRunning;
				results.Add(new BuildError(null, ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
				if (options.Callback != null) {
					options.Callback(results);
				}
			} else {
				isRunning = true;
				Thread thread = new Thread(new BuildRun(solution, project, options, this).RunMainBuild);
				thread.Name = "MSBuildEngine main worker";
				thread.SetApartmentState(ApartmentState.STA);
				thread.Start();
			}
		}
			public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
			{
				WorkbenchSingleton.SafeThreadAsyncCall(
					delegate {
						guiBuildProgressMonitor = null;
						GuiBuildFinished.RaiseEvent(null, new BuildEventArgs(buildable, options, results));
					});
			}
		bool BuildHasNoErrorsAndStillRunningTests(BuildResults results)
		{
			return (results.ErrorCount == 0) && IsRunningTest;
		}
Exemple #26
0
			public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
			{
				WorkbenchSingleton.SafeThreadAsyncCall(
					delegate {
						guiBuildCancellation = null;
						if (guiBuildTrackedFeature != null) {
							guiBuildTrackedFeature.EndTracking();
							guiBuildTrackedFeature = null;
						}
						string message;
						if (results.Result == BuildResultCode.Cancelled) {
							message = "${res:MainWindow.CompilerMessages.BuildCancelled}";
						} else {
							if (results.Result == BuildResultCode.Success)
								message = "${res:MainWindow.CompilerMessages.BuildFinished}";
							else
								message = "${res:MainWindow.CompilerMessages.BuildFailed}";
							
							if (results.ErrorCount > 0)
								message += " " + results.ErrorCount + " error(s)";
							if (results.WarningCount > 0)
								message += " " + results.WarningCount + " warning(s)";
						}
						statusBarService.SetMessage(message);
						ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results));
					});
			}
Exemple #27
0
		public async Task<BuildResults> BuildAsync(IEnumerable<IProject> projects, BuildOptions options)
		{
			if (projects == null)
				throw new ArgumentNullException("projects");
			if (options == null)
				throw new ArgumentNullException("options");
			SD.MainThread.VerifyAccess();
			if (guiBuildCancellation != null) {
				BuildResults results = new BuildResults();
				SD.StatusBar.SetMessage(ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
				BuildError error = new BuildError(null, ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
				results.Add(error);
				TaskService.Add(new SDTask(error));
				results.Result = BuildResultCode.MSBuildAlreadyRunning;
				return results;
			}
			var projectsList = projects.ToList();
			guiBuildCancellation = new CancellationTokenSource();
			try {
				using (var progressMonitor = SD.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token)) {
					if (BuildStarted != null)
						BuildStarted(this, new BuildEventArgs(projectsList, options));
					
					var trackedFeature = SD.AnalyticsMonitor.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build");
					SD.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}..."));
					IBuildable buildable;
					if (projectsList.Count == 1)
						buildable = projectsList[0];
					else
						buildable = new MultipleProjectBuildable(projectsList);
					
					buildable = buildModifiedProjectsOnly.WrapBuildable(buildable, options.BuildDetection);
					
					var sink = new UIBuildFeedbackSink(SD.OutputPad.BuildCategory, SD.StatusBar);
					// Actually run the build:
					var results = await BuildEngine.BuildAsync(buildable, options, sink, progressMonitor);
					
					string message;
					if (results.Result == BuildResultCode.Cancelled) {
						message = "${res:MainWindow.CompilerMessages.BuildCancelled}";
					} else {
						if (results.Result == BuildResultCode.Success)
							message = "${res:MainWindow.CompilerMessages.BuildFinished}";
						else
							message = "${res:MainWindow.CompilerMessages.BuildFailed}";
						
						if (results.ErrorCount > 0)
							message += " " + results.ErrorCount + " error(s)";
						if (results.WarningCount > 0)
							message += " " + results.WarningCount + " warning(s)";
					}
					SD.StatusBar.SetMessage(message);
					trackedFeature.EndTracking();
					if (BuildFinished != null)
						BuildFinished(this, new BuildEventArgs(projectsList, options, results));
					
					return results;
				}
			} finally {
				guiBuildCancellation = null;
			}
		}
		public BuildEventArgs(IBuildable buildable, BuildOptions options, BuildResults results)
		{
			if (buildable == null)
				throw new ArgumentNullException("buildable");
			if (options == null)
				throw new ArgumentNullException("options");
			this.Buildable = buildable;
			this.Options = options;
			this.Results = results;
		}
 public SharpDevelopLogger(MSBuildEngineWorker worker)
 {
     this.worker  = worker;
     this.results = worker.buildRun.currentResults;
 }