コード例 #1
1
ファイル: BuildEngine.cs プロジェクト: Altaxo/Altaxo
		/// <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));
			}
		}
コード例 #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;
            }
コード例 #3
0
 public void HandleError(BuildError error)
 {
     if (error.ErrorCode != "MSB3644")
     {
         nextFilter.HandleError(error);
     }
 }
コード例 #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));
     }
 }
コード例 #5
0
            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);
            }
コード例 #6
0
 public void ReportError(BuildError error)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(
         delegate {
         TaskService.Add(new Task(error));
     });
 }
コード例 #7
0
			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);
			}
コード例 #8
0
			public void HandleError(BuildError error)
			{
				if (insideTask)
					baseFilter.HandleError(error);
				else
					nextFilter.HandleError(error);
			}
コード例 #9
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;
            }
コード例 #10
0
 public void HandleError(BuildError error)
 {
     if (insideTask)
     {
         baseFilter.HandleError(error);
     }
     else
     {
         nextFilter.HandleError(error);
     }
 }
コード例 #11
0
			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);
			}
コード例 #12
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);
        }
コード例 #13
0
ファイル: BuildResults.cs プロジェクト: lisiynos/pascalabcnet
		/// <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++;
			}
		}
コード例 #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);
     }
 }
コード例 #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);
 }
コード例 #16
0
		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();
		}
コード例 #17
0
ファイル: BuildResults.cs プロジェクト: carlhuth/GenXSource
 /// <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++;
         }
     }
 }
コード例 #18
0
ファイル: BuildEngine.cs プロジェクト: Paccc/SharpDevelop
		/// <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;
		}
コード例 #19
0
ファイル: Task.cs プロジェクト: 2594636985/SharpDevelop
 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;
 }
コード例 #20
0
 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;
         }
     }
 }
コード例 #21
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();
		}
コード例 #22
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;
			}
コード例 #23
0
ファイル: BuildEngine.cs プロジェクト: Altaxo/Altaxo
			public void ReportError(BuildError error)
			{
				WorkbenchSingleton.SafeThreadAsyncCall(
					delegate {
						TaskService.Add(new Task(error));
					});
			}
コード例 #24
0
			public void ReportError(BuildError error)
			{
				engine.ReportError(this, error);
			}
コード例 #25
0
 public void ReportError(BuildError error)
 {
     sink.ReportError(error);
 }
コード例 #26
0
 public void ReportError(BuildError error)
 {
     SD.MainThread.InvokeAsyncAndForget(delegate {
         TaskService.Add(new SDTask(error));
     });
 }
コード例 #27
0
			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;
					}
				}
			}
コード例 #28
0
ファイル: BuildService.cs プロジェクト: Paccc/SharpDevelop
		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;
			}
		}
コード例 #29
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;
			}
コード例 #30
0
 public void ReportError(BuildError error)
 {
     SD.MainThread.InvokeAsyncAndForget(delegate {
         TaskService.Add(new SDTask(error));
     });
 }
コード例 #31
0
 public void ReportError(BuildError error)
 {
     feedbackSink.ReportError(error);
 }
コード例 #32
0
ファイル: Task.cs プロジェクト: kingjiang/SharpDevelopLite
		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;
		}
コード例 #33
0
 public void HandleError(BuildError error)
 {
     if (error.ErrorCode != "MSB3644")
         nextFilter.HandleError(error);
 }
コード例 #34
0
			public void HandleError(BuildError error)
			{
				error.ErrorText = FixEncoding(error.ErrorText);
				error.FileName = FixEncoding(error.FileName);
				nextFilter.HandleError(error);
			}
コード例 #35
0
				public void ReportError(BuildError error)
				{
					sink.ReportError(error);
				}
コード例 #36
0
			public void ReportError(BuildError error)
			{
			}
コード例 #37
0
			public void HandleError(BuildError error)
			{
				engine.ReportError(error);
			}
コード例 #38
0
ファイル: BuildEngine.cs プロジェクト: Altaxo/Altaxo
			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);
			}
コード例 #39
0
 public void ReportError(BuildError error)
 {
     engine.ReportError(this, error);
 }
コード例 #40
0
ファイル: BuildEngine.cs プロジェクト: Altaxo/Altaxo
		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);
			}
		}
コード例 #41
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;
            }
        }
コード例 #42
0
 public void HandleError(BuildError error)
 {
     engine.ReportError(error);
 }
コード例 #43
0
ファイル: ResourceManager.cs プロジェクト: maresja1/SDenc
        /// <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;
        }
コード例 #44
0
		public void ReportError(BuildError error)
		{
			feedbackSink.ReportError(error);
		}
コード例 #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();
        }
コード例 #46
0
			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);
			}
コード例 #47
0
 public void ReportError(BuildError error)
 {
 }