private void EventSource_ErrorRaised( BuildOutputLogger loggerSender, LazyFormattedBuildEventArgs e, ErrorLevel errorLevel) { try { bool verified = VerifyLoggerBuildEvent(loggerSender, e, errorLevel); if (!verified) { return; } int projectInstanceId = e.BuildEventContext.ProjectInstanceId; int projectContextId = e.BuildEventContext.ProjectContextId; BuildProjectContextEntry projectEntry = loggerSender.Projects.Find(t => t.InstanceId == projectInstanceId && t.ContextId == projectContextId); if (projectEntry == null) { TraceManager.Trace( string.Format( "Project entry not found by ProjectInstanceId='{0}' and ProjectContextId='{1}'.", projectInstanceId, projectContextId), EventLogEntryType.Warning); return; } if (projectEntry.IsInvalid) { return; } ProjectItem projectItem; if (!GetProjectItem(projectEntry, out projectItem)) { projectEntry.IsInvalid = true; return; } BuildedProject buildedProject = _buildedProjects[projectItem]; buildedProject.ErrorsBox.Keep(errorLevel, e); OnErrorRaised(this, new BuildErrorRaisedEventArgs(errorLevel, buildedProject)); } catch (Exception ex) { ex.TraceUnknownException(); } }
private bool GetProjectItem(BuildProjectContextEntry projectEntry, out ProjectItem projectItem) { projectItem = projectEntry.ProjectItem; if (projectItem != null) { return(true); } string projectFile = projectEntry.FileName; if (SolutionProjectsExtensions.ProjectIsHidden(projectFile)) { return(false); } IDictionary <string, string> projectProperties = projectEntry.Properties; if (projectProperties.ContainsKey("Configuration") && projectProperties.ContainsKey("Platform")) { // TODO: Use find by FullNameProjectDefinition for the Batch Build only. string projectConfiguration = projectProperties["Configuration"]; string projectPlatform = projectProperties["Platform"]; var projectDefinition = new FullNameProjectDefinition(projectFile, projectConfiguration, projectPlatform); projectItem = _findProjectItem(projectDefinition, FindProjectProperty.FullNameProjectDefinition); if (projectItem == null) { TraceManager.Trace( string.Format("Project Item not found by: FullName='{0}', Configuration='{1}, Platform='{2}'.", projectDefinition.FullName, projectDefinition.Configuration, projectDefinition.Platform), EventLogEntryType.Warning); return(false); } } else { projectItem = _findProjectItem(projectFile, FindProjectProperty.FullName); if (projectItem == null) { TraceManager.Trace( string.Format("Project Item not found by FullName='{0}'.", projectFile), EventLogEntryType.Warning); return(false); } } projectEntry.ProjectItem = projectItem; return(true); }
private bool GetProjectItem(BuildProjectContextEntry projectEntry, out ProjectItem projectItem) { projectItem = projectEntry.ProjectItem; if (projectItem != null) return true; string projectFile = projectEntry.FileName; if (SolutionProjectsExtensions.ProjectIsHidden(projectFile)) return false; IDictionary<string, string> projectProperties = projectEntry.Properties; if (projectProperties.ContainsKey("Configuration") && projectProperties.ContainsKey("Platform")) { // TODO: Use find by FullNameProjectDefinition for the Batch Build only. string projectConfiguration = projectProperties["Configuration"]; string projectPlatform = projectProperties["Platform"]; var projectDefinition = new FullNameProjectDefinition(projectFile, projectConfiguration, projectPlatform); projectItem = _findProjectItem(projectDefinition, FindProjectProperty.FullNameProjectDefinition); if (projectItem == null) { TraceManager.Trace( string.Format("Project Item not found by: FullName='{0}', Configuration='{1}, Platform='{2}'.", projectDefinition.FullName, projectDefinition.Configuration, projectDefinition.Platform), EventLogEntryType.Warning); return false; } } else { projectItem = _findProjectItem(projectFile, FindProjectProperty.FullName); if (projectItem == null) { TraceManager.Trace( string.Format("Project Item not found by FullName='{0}'.", projectFile), EventLogEntryType.Warning); return false; } } projectEntry.ProjectItem = projectItem; return true; }