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
            // TODO: Add XmlDocBloc to MSBuildError.AppendError()
            void AppendError(string file, int lineNumber, int columnNumber, string code, string message, bool isWarning)
            {
                if (string.Equals(file, activeTaskName, StringComparison.OrdinalIgnoreCase))
                {
                    file = "";
                }
                else if (FileUtility.IsValidPath(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 = "";
                    }
                    //TODO: Do we have to check for other SDKs here.
                    else if (file.EndsWith(".targets", StringComparison.OrdinalIgnoreCase) &&
                             (FileUtility.IsBaseDirectory(FileUtility.NetFrameworkInstallRoot, file) ||
                              FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, file)))
                    {
                        file = "";
                    }
                }
                FlushCurrentError();
                BuildError error = new BuildError(file, lineNumber, columnNumber, code, message);

                error.IsWarning = isWarning;
                worker.currentErrorOrWarning = error;
            }
 public void HandleError(BuildError error)
 {
     if (error.ErrorCode != "MSB3644")
     {
         nextFilter.HandleError(error);
     }
 }
Exemple #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 (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));
     }
 }
            void AppendError(string file, int lineNumber, int columnNumber, string code, string message, string projectFile, string subcategory, string helpKeyword, bool isWarning)
            {
                if (string.Equals(file, activeTaskName, StringComparison.OrdinalIgnoreCase))
                {
                    file = "";
                }
                else if (FileUtility.IsValidPath(file))
                {
                    bool isShortFileName = file == Path.GetFileNameWithoutExtension(file);
                    if (engine.ProjectFileName != null)
                    {
                        file = Path.Combine(Path.GetDirectoryName(engine.ProjectFileName), file);
                    }
                    if (isShortFileName && !File.Exists(file))
                    {
                        file = "";
                    }
                    //TODO: Do we have to check for other SDKs here.
                    else if (file.EndsWith(".targets", StringComparison.OrdinalIgnoreCase) &&
                             (FileUtility.IsBaseDirectory(FileUtility.NetFrameworkInstallRoot, file) ||
                              FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, file)))
                    {
                        file = "";
                    }
                }
                BuildError error = new BuildError(file, lineNumber, columnNumber, code, message);

                error.IsWarning   = isWarning;
                error.Subcategory = subcategory;
                error.HelpKeyword = helpKeyword;
                engine.loggerChain.HandleError(error);
            }
Exemple #6
0
 public void ReportError(BuildError error)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(
         delegate {
         TaskService.Add(new Task(error));
     });
 }
			public void HandleError(BuildError error)
			{
				error.ErrorText = FixEncoding(error.ErrorText);
				error.FileName = FixEncoding(error.FileName);
				error.Column = FixColumn(error.FileName, error.Line, error.Column);
				nextFilter.HandleError(error);
			}
			public void HandleError(BuildError error)
			{
				if (insideTask)
					baseFilter.HandleError(error);
				else
					nextFilter.HandleError(error);
			}
            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;
            }
 public void HandleError(BuildError error)
 {
     if (insideTask)
     {
         baseFilter.HandleError(error);
     }
     else
     {
         nextFilter.HandleError(error);
     }
 }
			public void HandleError(BuildError error)
			{
				LoggingService.Debug("FxCopLogger got " + error.ToString());
				
				string[] moreData = (error.Subcategory ?? "").Split('|');
				string checkId = error.ErrorCode;
				error.ErrorCode = (error.ErrorCode != null) ? error.ErrorCode.Split(':')[0] : null;
				if (FileUtility.IsValidPath(error.FileName) &&
				    Path.GetFileName(error.FileName) == "SharpDevelop.CodeAnalysis.targets")
				{
					error.FileName = null;
				}
				IProject project = ProjectService.GetProject(engineWorker.ProjectFileName);
				if (project != null) {
					IProjectContent pc = ParserService.GetProjectContent(project);
					if (pc != null) {
						if (error.FileName != null) {
							int pos = error.FileName.IndexOf("positionof#", StringComparison.Ordinal);
							if (pos >= 0) {
								string memberName = error.FileName.Substring(pos+11);
								FilePosition filePos = GetPosition(pc, memberName);
								if (filePos.IsEmpty == false && filePos.CompilationUnit != null) {
									error.FileName = filePos.FileName ?? "";
									error.Line = filePos.Line;
									error.Column = filePos.Column;
								} else {
									error.FileName = null;
								}
							}
						}
						
						if (moreData.Length > 1 && !string.IsNullOrEmpty(moreData[0])) {
							error.Tag = new FxCopTaskTag {
								ProjectContent = pc,
								TypeName = moreData[0],
								MemberName = moreData[1],
								Category = error.HelpKeyword,
								CheckID = checkId
							};
						} else {
							error.Tag = new FxCopTaskTag {
								ProjectContent = pc,
								Category = error.HelpKeyword,
								CheckID = checkId
							};
						}
						error.ContextMenuAddInTreeEntry = "/SharpDevelop/Pads/ErrorList/CodeAnalysisTaskContextMenu";
						if (moreData.Length > 2) {
							(error.Tag as FxCopTaskTag).MessageID = moreData[2];
						}
					}
				}
				nextChainElement.HandleError(error);
			}
        /// <summary>
        /// Starts to run a build.
        /// </summary>
        /// <param name="project">The project/solution to build</param>
        /// <param name="options">The build options that should be used</param>
        /// <param name="buildFeedbackSink">The build feedback sink that receives the build output.
        /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
        /// will ensure that output from two projects building in parallel isn't interleaved.</param>
        /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
        /// when the build completes.</param>
        public static Task <BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            BuildEngine engine = new BuildEngine(options, project);

            engine.buildStart = DateTime.Now;
            engine.combinedBuildFeedbackSink = buildFeedbackSink;
            engine.progressMonitor           = progressMonitor;
            try {
                engine.rootNode = engine.CreateBuildGraph(project);
            } catch (CyclicDependencyException ex) {
                BuildError error;
                if (ex.Project1 != null && ex.Project2 != null)
                {
                    error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name);
                }
                else
                {
                    error = new BuildError(null, "Cyclic dependency");
                }
                engine.results.Add(error);
                if (engine.combinedBuildFeedbackSink != null)
                {
                    engine.combinedBuildFeedbackSink.ReportError(error);
                    engine.combinedBuildFeedbackSink.ReportMessage(error.ToRichText());
                }

                engine.results.Result = BuildResultCode.BuildFileError;
                engine.ReportDone();
                return(engine.tcs.Task);
            }

            engine.workersToStart = options.ParallelProjectCount;
            if (engine.workersToStart < 1)
            {
                engine.workersToStart = 1;
            }

            engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);

            engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
            engine.StartBuildProjects();
            engine.UpdateProgressTaskName();
            return(engine.tcs.Task);
        }
Exemple #13
0
		/// <summary>
		/// Adds a build error/warning to the results.
		/// This method is thread-safe.
		/// </summary>
		public void Add(BuildError error)
		{
			if (error == null)
				throw new ArgumentNullException("error");
			lock (errors) {
				readOnlyErrors = null;
				errors.Add(error);
				if (error.IsWarning)
					warningCount++;
				else
					errorCount++;
			}
		}
Exemple #14
0
 void ReportError(BuildNode source, BuildError error)
 {
     if (!error.IsWarning)
     {
         source.hasErrors = true;
     }
     results.Add(error);
     ReportMessage(source, error.ToString());
     if (combinedBuildFeedbackSink != null)
     {
         combinedBuildFeedbackSink.ReportError(error);
     }
 }
Exemple #15
0
 public void ReportError(BuildError error)
 {
     if (error.IsWarning)
     {
         if (perNodeProgressMonitor.Status != OperationStatus.Error)
         {
             perNodeProgressMonitor.Status = OperationStatus.Warning;
         }
     }
     else
     {
         perNodeProgressMonitor.Status = OperationStatus.Error;
     }
     engine.ReportError(this, error);
 }
		public void Init()
		{
			base.InitBase();
			
			MockCSharpProject project = new MockCSharpProject();
			context.MockUnitTestsPad.AddProject(project);
			
			buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun();
			context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun);
			
			runTestCommand.Run();
			
			FileName fileName = new FileName("test.cs");
			context.MockTaskService.Add(new Task(fileName, String.Empty, 1, 1, TaskType.Error));
			
			BuildError error = new BuildError();
			buildProjectBeforeTestRun.LastBuildResults.Add(error);
			buildProjectBeforeTestRun.FireBuildCompleteEvent();
		}
Exemple #17
0
 /// <summary>
 /// Adds a build error/warning to the results.
 /// This method is thread-safe.
 /// </summary>
 public void Add(BuildError error)
 {
     if (error == null)
     {
         throw new ArgumentNullException("error");
     }
     lock (errors) {
         readOnlyErrors = null;
         errors.Add(error);
         if (error.IsWarning)
         {
             warningCount++;
         }
         else
         {
             errorCount++;
         }
     }
 }
Exemple #18
0
		/// <summary>
		/// Starts to run a build.
		/// </summary>
		/// <param name="project">The project/solution to build</param>
		/// <param name="options">The build options that should be used</param>
		/// <param name="buildFeedbackSink">The build feedback sink that receives the build output.
		/// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
		/// will ensure that output from two projects building in parallel isn't interleaved.</param>
		/// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
		/// when the build completes.</param>
		public static Task<BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			
			BuildEngine engine = new BuildEngine(options, project);
			engine.buildStart = DateTime.Now;
			engine.combinedBuildFeedbackSink = buildFeedbackSink;
			engine.progressMonitor = progressMonitor;
			try {
				engine.rootNode = engine.CreateBuildGraph(project);
			} catch (CyclicDependencyException ex) {
				BuildError error;
				if (ex.Project1 != null && ex.Project2 != null)
					error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name);
				else
					error = new BuildError(null, "Cyclic dependency");
				engine.results.Add(error);
				if (engine.combinedBuildFeedbackSink != null) {
					engine.combinedBuildFeedbackSink.ReportError(error);
					engine.combinedBuildFeedbackSink.ReportMessage(error.ToRichText());
				}
				
				engine.results.Result = BuildResultCode.BuildFileError;
				engine.ReportDone();
				return engine.tcs.Task;
			}
			
			engine.workersToStart = options.ParallelProjectCount;
			if (engine.workersToStart < 1)
				engine.workersToStart = 1;
			
			engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);
			
			engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
			engine.StartBuildProjects();
			engine.UpdateProgressTaskName();
			return engine.tcs.Task;
		}
Exemple #19
0
 public SDTask(BuildError error)
 {
     if (error == null)
         throw new ArgumentNullException("error");
     type = error.IsWarning ? TaskType.Warning : TaskType.Error;
     int line = Math.Max(error.Line, 1);
     int column = Math.Max(error.Column, 1);
     if (!string.IsNullOrEmpty(error.FileName)) {
         hasLocation = error.Line >= 1;
         this.position = new PermanentAnchor(FileName.Create(error.FileName), line, column);
         position.Deleted += position_Deleted;
     }
     if (string.IsNullOrEmpty(error.ErrorCode)) {
         description = error.ErrorText;
     } else {
         description = error.ErrorText + " (" + error.ErrorCode + ")";
     }
     if (error.ContextMenuAddInTreeEntry != null) {
         ContextMenuAddInTreeEntry = error.ContextMenuAddInTreeEntry;
     }
     this.Tag = error.Tag;
     this.BuildError = error;
 }
 void TransformBuildError(BuildError error)
 {
     if (error.IsWarning)
     {
         // treat "MSB3274: The primary reference "{0}" could not be resolved because it was
         // built against the "{1}" framework. This is a higher version than the currently
         // targeted framework "{2}"." as error.
         if ("MSB3274".Equals(error.ErrorCode, StringComparison.OrdinalIgnoreCase))
         {
             error.IsWarning = false;
             return;
         }
         // treat "MSB3275: The primary reference "{0}" could not be resolved because it has
         // an indirect dependency on the assembly "{1}" which was built against the "{2}"
         // framework. This is a higher version than the currently targeted framework "{3}"."
         // as error.
         if ("MSB3275".Equals(error.ErrorCode, StringComparison.OrdinalIgnoreCase))
         {
             error.IsWarning = false;
             return;
         }
     }
 }
		/// <summary>
		/// Starts to run a build.
		/// </summary>
		/// <param name="project">The project/solution to build</param>
		/// <param name="options">The build options that should be used</param>
		/// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output.
		/// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
		/// will ensure that output from two projects building in parallel isn't interleaved.</param>
		/// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
		/// when the build completes.</param>
		public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink)
		{
			if (project == null)
				throw new ArgumentNullException("solution");
			if (options == null)
				throw new ArgumentNullException("options");
			
			Solution solution = project.ParentSolution;
			if (solution == null)
				throw new ArgumentException("project.ParentSolution must not be null", "project");
			
			if (string.IsNullOrEmpty(options.SolutionConfiguration))
				options.SolutionConfiguration = solution.Preferences.ActiveConfiguration;
			if (string.IsNullOrEmpty(options.SolutionPlatform))
				options.SolutionPlatform = solution.Preferences.ActivePlatform;
			
			BuildEngine engine = new BuildEngine(options, project);
			engine.buildStart = DateTime.Now;
			engine.combinedBuildFeedbackSink = realtimeBuildFeedbackSink;
			engine.progressMonitor = realtimeBuildFeedbackSink.ProgressMonitor;
			try {
				engine.rootNode = engine.CreateBuildGraph(project);
			} catch (CyclicDependencyException ex) {
				BuildError error;
				if (ex.Project1 != null && ex.Project2 != null)
					error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name);
				else
					error = new BuildError(null, "Cyclic dependency");
				engine.results.Add(error);
				if (engine.combinedBuildFeedbackSink != null) {
					engine.combinedBuildFeedbackSink.ReportError(error);
					engine.combinedBuildFeedbackSink.ReportMessage(error.ToString());
				}
				
				engine.results.Result = BuildResultCode.BuildFileError;
				engine.ReportDone();
				return;
			}
			
			engine.workersToStart = options.ParallelProjectCount;
			if (engine.workersToStart < 1)
				engine.workersToStart = 1;
			
			engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);
			
			engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
			engine.StartBuildProjects();
			engine.UpdateProgressTaskName();
		}
			// TODO: Add XmlDocBloc to MSBuildError.AppendError()
			void AppendError(string file, int lineNumber, int columnNumber, string code, string message, bool isWarning)
			{
				if (string.Equals(file, activeTaskName, StringComparison.OrdinalIgnoreCase)) {
					file = "";
				} else if (FileUtility.IsValidPath(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 = "";
					}
					//TODO: Do we have to check for other SDKs here.
					else if (file.EndsWith(".targets", StringComparison.OrdinalIgnoreCase)
					         && (FileUtility.IsBaseDirectory(FileUtility.NetFrameworkInstallRoot, file)
					             || FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, file)))
					{
						file = "";
					}
				}
				FlushCurrentError();
				BuildError error = new BuildError(file, lineNumber, columnNumber, code, message);
				error.IsWarning = isWarning;
				worker.currentErrorOrWarning = error;
			}
Exemple #23
0
			public void ReportError(BuildError error)
			{
				WorkbenchSingleton.SafeThreadAsyncCall(
					delegate {
						TaskService.Add(new Task(error));
					});
			}
			public void ReportError(BuildError error)
			{
				engine.ReportError(this, error);
			}
 public void ReportError(BuildError error)
 {
     sink.ReportError(error);
 }
 public void ReportError(BuildError error)
 {
     SD.MainThread.InvokeAsyncAndForget(delegate {
         TaskService.Add(new SDTask(error));
     });
 }
			void TransformBuildError(BuildError error)
			{
				if (error.IsWarning) {
					// treat "MSB3274: The primary reference "{0}" could not be resolved because it was 
					// built against the "{1}" framework. This is a higher version than the currently 
					// targeted framework "{2}"." as error.
					if ("MSB3274".Equals(error.ErrorCode, StringComparison.OrdinalIgnoreCase)) {
						error.IsWarning = false;
						return;
					}
					// treat "MSB3275: The primary reference "{0}" could not be resolved because it has
					// an indirect dependency on the assembly "{1}" which was built against the "{2}"
					// framework. This is a higher version than the currently targeted framework "{3}"."
					// as error.
					if ("MSB3275".Equals(error.ErrorCode, StringComparison.OrdinalIgnoreCase)) {
						error.IsWarning = false;
						return;
					}
				}
			}
Exemple #28
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;
			}
		}
			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;
			}
Exemple #30
0
 public void ReportError(BuildError error)
 {
     SD.MainThread.InvokeAsyncAndForget(delegate {
         TaskService.Add(new SDTask(error));
     });
 }
Exemple #31
0
 public void ReportError(BuildError error)
 {
     feedbackSink.ReportError(error);
 }
Exemple #32
0
		public Task(BuildError error)
		{
			type         = error.IsWarning ? TaskType.Warning : TaskType.Error;
			column       = Math.Max(error.Column - 1, 0);
			line         = Math.Max(error.Line - 1, 0);
			fileName     = error.FileName;
			if (string.IsNullOrEmpty(error.ErrorCode)) {
				description = error.ErrorText;
			} else {
				description = error.ErrorText + " (" + error.ErrorCode + ")";
			}
			if (error.ContextMenuAddInTreeEntry != null) {
				contextMenuAddInTreeEntry = error.ContextMenuAddInTreeEntry;
			}
			tag = error.Tag;
			this.BuildError = error;
		}
 public void HandleError(BuildError error)
 {
     if (error.ErrorCode != "MSB3644")
         nextFilter.HandleError(error);
 }
			public void HandleError(BuildError error)
			{
				error.ErrorText = FixEncoding(error.ErrorText);
				error.FileName = FixEncoding(error.FileName);
				nextFilter.HandleError(error);
			}
				public void ReportError(BuildError error)
				{
					sink.ReportError(error);
				}
			public void ReportError(BuildError error)
			{
			}
			public void HandleError(BuildError error)
			{
				engine.ReportError(error);
			}
Exemple #38
0
			public void ReportError(BuildError error)
			{
				if (error.IsWarning) {
					if (perNodeProgressMonitor.Status != OperationStatus.Error)
						perNodeProgressMonitor.Status = OperationStatus.Warning;
				} else {
					perNodeProgressMonitor.Status = OperationStatus.Error;
				}
				engine.ReportError(this, error);
			}
Exemple #39
0
 public void ReportError(BuildError error)
 {
     engine.ReportError(this, error);
 }
Exemple #40
0
		void ReportError(BuildNode source, BuildError error)
		{
			if (!error.IsWarning)
				source.hasErrors = true;
			results.Add(error);
			ReportMessage(source, error.ToString());
			if (combinedBuildFeedbackSink != null) {
				combinedBuildFeedbackSink.ReportError(error);
			}
		}
        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 void HandleError(BuildError error)
 {
     engine.ReportError(error);
 }
Exemple #43
0
        /// <summary>
        /// Rebuilds assembly given the dirty files.
        /// </summary>
        /// <param name="filesToCompile">Dirty files to be recompiled in new assembly.</param>
        /// <returns>Path of the new assembly.</returns>
        private string rebuildAssembly(List<string> filesToCompile)
        {
            if(project.IsStartable){
                NewAssemblyName = project.AssemblyName + "_enc.exe";
            } else {
                NewAssemblyName = project.AssemblyName + "_enc.dll";
            }
            string path = TemporaryPath + NewAssemblyName;
            CompilerErrors errs = CSharpBackgroundCompiler.RecompileWithName(path,filesToCompile);

            CompileSuccessful = (errs != null && !errs.HasErrors);
            WorkbenchSingleton.SafeThreadAsyncCall(
                delegate() {
                    if(!CompileSuccessful && errs != null)
                    {
                        foreach(CompilerError err in errs){
                            BuildError error = new BuildError(err.FileName,err.Line,err.Column,err.ErrorNumber,err.ErrorText);
                            error.IsWarning = err.IsWarning;
                            TaskService.Add(new Task(error));
                        }
                    } else {
                        TaskService.Clear();
                    }
                }
            );
            return path;
        }
		public void ReportError(BuildError error)
		{
			feedbackSink.ReportError(error);
		}
Exemple #45
0
        /// <summary>
        /// Starts to run a build.
        /// </summary>
        /// <param name="project">The project/solution to build</param>
        /// <param name="options">The build options that should be used</param>
        /// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output.
        /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
        /// will ensure that output from two projects building in parallel isn't interleaved.</param>
        /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
        /// when the build completes.</param>
        public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink)
        {
            if (project == null)
            {
                throw new ArgumentNullException("solution");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            Solution solution = project.ParentSolution;

            if (solution == null)
            {
                throw new ArgumentException("project.ParentSolution must not be null", "project");
            }

            if (string.IsNullOrEmpty(options.SolutionConfiguration))
            {
                options.SolutionConfiguration = solution.Preferences.ActiveConfiguration;
            }
            if (string.IsNullOrEmpty(options.SolutionPlatform))
            {
                options.SolutionPlatform = solution.Preferences.ActivePlatform;
            }

            BuildEngine engine = new BuildEngine(options, project);

            engine.buildStart = DateTime.Now;
            engine.combinedBuildFeedbackSink = realtimeBuildFeedbackSink;
            engine.progressMonitor           = realtimeBuildFeedbackSink.ProgressMonitor;
            try {
                engine.rootNode = engine.CreateBuildGraph(project);
            } catch (CyclicDependencyException ex) {
                BuildError error;
                if (ex.Project1 != null && ex.Project2 != null)
                {
                    error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name);
                }
                else
                {
                    error = new BuildError(null, "Cyclic dependency");
                }
                engine.results.Add(error);
                if (engine.combinedBuildFeedbackSink != null)
                {
                    engine.combinedBuildFeedbackSink.ReportError(error);
                    engine.combinedBuildFeedbackSink.ReportMessage(error.ToString());
                }

                engine.results.Result = BuildResultCode.BuildFileError;
                engine.ReportDone();
                return;
            }

            engine.workersToStart = options.ParallelProjectCount;
            if (engine.workersToStart < 1)
            {
                engine.workersToStart = 1;
            }

            engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);

            engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
            engine.StartBuildProjects();
            engine.UpdateProgressTaskName();
        }
			void AppendError(string file, int lineNumber, int columnNumber, string code, string message, string projectFile, string subcategory, string helpKeyword, bool isWarning)
			{
				if (string.Equals(file, activeTaskName, StringComparison.OrdinalIgnoreCase)) {
					file = "";
				} else if (FileUtility.IsValidPath(file)) {
					bool isShortFileName = file == Path.GetFileNameWithoutExtension(file);
					if (engine.ProjectFileName != null) {
						file = Path.Combine(Path.GetDirectoryName(engine.ProjectFileName), file);
					}
					if (isShortFileName && !File.Exists(file)) {
						file = "";
					}
					//TODO: Do we have to check for other SDKs here.
					else if (file.EndsWith(".targets", StringComparison.OrdinalIgnoreCase)
					         && (FileUtility.IsBaseDirectory(FileUtility.NetFrameworkInstallRoot, file)
					             || FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, file)))
					{
						file = "";
					}
				}
				BuildError error = new BuildError(file, lineNumber, columnNumber, code, message);
				error.IsWarning = isWarning;
				error.Subcategory = subcategory;
				error.HelpKeyword = helpKeyword;
				engine.loggerChain.HandleError(error);
			}
Exemple #47
0
 public void ReportError(BuildError error)
 {
 }