Esempio n. 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));
			}
		}
Esempio n. 2
0
 void BuildCancelled(object sender, EventArgs e)
 {
     lock (this) {
         if (buildIsDone)
         {
             return;
         }
         buildIsCancelled = true;
     }
     results.Add(new BuildError(null, "Build was cancelled."));
 }
Esempio n. 3
0
 void BuildCancelled()
 {
     lock (this) {
         if (buildIsDone)
         {
             return;
         }
         buildIsCancelled = true;
     }
     results.Add(new BuildError(null, StringParser.Parse("${res:MainWindow.CompilerMessages.BuildCancelled}")));
 }
Esempio n. 4
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);
     }
 }
Esempio n. 5
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));
     }
 }
Esempio n. 6
0
            void AppendError(string file, int lineNumber, int columnNumber, string code, string message, bool isWarning)
            {
                if (string.Equals(file, activeTaskName, StringComparison.InvariantCultureIgnoreCase))
                {
                    file = "";
                }
                else if (FileUtility.IsValidFileName(file))
                {
                    bool isShortFileName = file == Path.GetFileNameWithoutExtension(file);
                    if (worker.CurrentProjectFile != null)
                    {
                        file = Path.Combine(Path.GetDirectoryName(worker.CurrentProjectFile), file);
                    }
                    if (isShortFileName && !File.Exists(file))
                    {
                        file = "";
                    }
                }
                FlushCurrentError();
                BuildError error = new BuildError(file, lineNumber, columnNumber, code, message);

                error.IsWarning = isWarning;
                results.Add(error);
                worker.currentErrorOrWarning = error;
            }
Esempio n. 7
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();
     }
 }
Esempio n. 8
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);
			}
		}
Esempio n. 9
0
 BuildResults GetBuildTimeoutResult()
 {
     var results = new BuildResults { Result = BuildResultCode.Error };
     results.Add(new BuildError(String.Empty, "Timed out waiting for build to complete."));
     return results;
 }
Esempio n. 10
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;
            }
        }
Esempio n. 11
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;
			}
		}
Esempio n. 12
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();
			}
		}