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(); } }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="buildMessageEventArgs">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs buildMessageEventArgs, string message) { LogProcessNode node = this; if (buildMessageEventArgs.BuildEventContext.TaskId > 0) { node = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId) .GetTargetById(buildMessageEventArgs.BuildEventContext.TargetId) .GetTaskById(buildMessageEventArgs.BuildEventContext.TaskId); } else if (buildMessageEventArgs.BuildEventContext.TargetId > 0) { node = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId) .GetTargetById(buildMessageEventArgs.BuildEventContext.TargetId); } else if (buildMessageEventArgs.BuildEventContext.ProjectContextId > 0) { node = GetOrAddProject(buildMessageEventArgs.BuildEventContext.ProjectContextId); } node.AddMessage(new Message(message, buildMessageEventArgs.Timestamp)); }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="args">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs args, string message) { message = stringTable.Intern(message); TreeNode node = null; var messageNode = new Message { Text = message, Timestamp = args.Timestamp }; object nodeToAdd = messageNode; if (args.BuildEventContext?.TaskId > 0) { node = construction .GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId) .GetTaskById(args.BuildEventContext.TaskId); var task = node as Task; if (task != null) { if (task.Name == "ResolveAssemblyReference") { Folder inputs = task.GetOrCreateNodeWithName <Folder>("Inputs"); Folder results = task.FindChild <Folder>("Results"); node = results ?? inputs; if (message.StartsWith(" ")) { message = message.Substring(4); var parameter = node.FindLastChild <Parameter>(); if (parameter != null) { if (!string.IsNullOrWhiteSpace(message)) { node = parameter; if (message.StartsWith(" ")) { message = message.Substring(4); var lastItem = parameter.FindLastChild <Item>(); // only indent if it's not a "For SearchPath..." message - that one needs to be directly under parameter if (lastItem != null && !message.StartsWith("For SearchPath")) { node = lastItem; } } if (!string.IsNullOrEmpty(message)) { if (message.IndexOf('=') != -1) { var kvp = Utilities.ParseNameValue(message); node.AddChild(new Metadata { Name = stringTable.Intern(kvp.Key.TrimEnd(space)), Value = stringTable.Intern(kvp.Value.TrimStart(space)) }); } else { node.AddChild(new Item() { Text = stringTable.Intern(message) }); } } } return; } } else { if (results == null) { bool isResult = message.StartsWith("Unified primary reference ") || message.StartsWith("Primary reference ") || message.StartsWith("Dependency ") || message.StartsWith("Unified Dependency "); if (isResult) { results = task.GetOrCreateNodeWithName <Folder>("Results"); node = results; } else { node = inputs; } } else { node = results; } node.GetOrCreateNodeWithName <Parameter>(stringTable.Intern(message.TrimEnd(':'))); return; } } else if (task.Name == "MSBuild") { if (message.StartsWith("Global Properties") || message.StartsWith("Additional Properties") || message.StartsWith("Overriding Global Properties") || message.StartsWith("Removing Properties")) { node.GetOrCreateNodeWithName <Folder>(message); return; } node = node.FindLastChild <Folder>(); if (message[0] == ' ' && message[1] == ' ') { message = message.Substring(2); } var kvp = Utilities.ParseNameValue(message); if (kvp.Value == "") { nodeToAdd = new Item { Text = stringTable.Intern(kvp.Key) }; } else { nodeToAdd = new Property { Name = stringTable.Intern(kvp.Key), Value = stringTable.Intern(kvp.Value) }; } } } } else if (args.BuildEventContext?.TargetId > 0) { node = construction .GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId); if (message.StartsWith("Task") && message.Contains("skipped")) { messageNode.IsLowRelevance = true; } } else if (args.BuildEventContext?.ProjectContextId > 0) { var project = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId); node = project; if (message.StartsWith("Target") && message.Contains("skipped")) { var targetName = stringTable.Intern(Utilities.ParseQuotedSubstring(message)); if (targetName != null) { node = project.GetOrAddTargetByName(targetName); messageNode.IsLowRelevance = true; } } } else if (Reflector.GetEvaluationId(args.BuildEventContext) is int evaluationId && evaluationId != -1) { var evaluation = construction.EvaluationFolder; var project = evaluation.FindChild <Project>(p => p.Id == evaluationId); node = project; if (node != null && node.FindChild <Message>(message) != null) { // avoid duplicate messages return; } } if (node == null) { node = construction.Build; if (IsEvaluationMessage(message)) { if (!evaluationMessagesAlreadySeen.Add(message)) { return; } node = construction.EvaluationFolder; } else if (message.StartsWith("The target") && message.Contains("does not exist in the project, and will be ignored")) { var folder = construction.EvaluationFolder; node = folder; messageNode.IsLowRelevance = true; } else if (args.BuildEventContext != null && (args.BuildEventContext.NodeId == 0 && args.BuildEventContext.ProjectContextId == 0 && args.BuildEventContext.ProjectInstanceId == 0 && args.BuildEventContext.TargetId == 0 && args.BuildEventContext.TaskId == 0)) { // must be Detailed Build Summary // https://github.com/Microsoft/msbuild/blob/master/src/XMakeBuildEngine/BackEnd/Components/Scheduler/Scheduler.cs#L509 node = construction.Build.GetOrCreateNodeWithName <Folder>("DetailedSummary"); } } node.AddChild(nodeToAdd); }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="args">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs args, string message) { message = stringTable.Intern(message); TreeNode node = null; var messageNode = new Message { Text = message, Timestamp = args.Timestamp }; object nodeToAdd = messageNode; if (args.BuildEventContext?.TaskId > 0) { node = construction .GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId) .GetTaskById(args.BuildEventContext.TaskId); var task = node as Task; if (task != null) { if (task.Name == "ResolveAssemblyReference") { Folder inputs = task.GetOrCreateNodeWithName <Folder>("Inputs"); Folder results = task.FindChild <Folder>("Results"); node = results ?? inputs; if (message.StartsWith(" ")) { message = message.Substring(4); var parameter = node.FindLastChild <Parameter>(); if (parameter != null) { bool thereWasAConflict = parameter.ToString().StartsWith(Strings.ThereWasAConflictPrefix); if (thereWasAConflict) { HandleThereWasAConflict(parameter, message, stringTable); return; } if (!string.IsNullOrWhiteSpace(message)) { node = parameter; if (message.StartsWith(" ")) { message = message.Substring(4); var lastItem = parameter.FindLastChild <Item>(); // only indent if it's not a "For SearchPath..." message - that one needs to be directly under parameter // also don't indent if it's under AssemblyFoldersEx in Results if (lastItem != null && !message.StartsWith(Strings.ForSearchPathPrefix) && !parameter.Name.StartsWith("AssemblyFoldersEx")) { node = lastItem; } } if (!string.IsNullOrEmpty(message)) { var equals = message.IndexOf('='); if (equals != -1) { var kvp = TextUtilities.ParseNameValue(message); node.AddChild(new Metadata { Name = stringTable.Intern(kvp.Key.TrimEnd(space)), Value = stringTable.Intern(kvp.Value.TrimStart(space)) }); } else { node.AddChild(new Item() { Text = stringTable.Intern(message) }); } } } return; } } else { if (results == null) { bool isResult = message.StartsWith(Strings.UnifiedPrimaryReferencePrefix) || message.StartsWith(Strings.PrimaryReferencePrefix) || message.StartsWith(Strings.DependencyPrefix) || message.StartsWith(Strings.UnifiedDependencyPrefix) || message.StartsWith(Strings.AssemblyFoldersExLocation) || message.StartsWith(Strings.ThereWasAConflictPrefix); if (isResult) { results = task.GetOrCreateNodeWithName <Folder>("Results"); node = results; } else { node = inputs; } } else { node = results; } node.GetOrCreateNodeWithName <Parameter>(stringTable.Intern(message.TrimEnd(':'))); return; } } else if (task.Name == "MSBuild") { if (message.StartsWith(Strings.GlobalPropertiesPrefix) || message.StartsWith(Strings.AdditionalPropertiesPrefix) || message.StartsWith(Strings.OverridingGlobalPropertiesPrefix) || message.StartsWith(Strings.RemovingPropertiesPrefix)) { node.GetOrCreateNodeWithName <Folder>(message); return; } node = node.FindLastChild <Folder>(); if (message[0] == ' ' && message[1] == ' ') { message = message.Substring(2); } var kvp = TextUtilities.ParseNameValue(message); if (kvp.Value == "") { nodeToAdd = new Item { Text = stringTable.Intern(kvp.Key) }; } else { nodeToAdd = new Property { Name = stringTable.Intern(kvp.Key), Value = stringTable.Intern(kvp.Value) }; } } } } else if (args.BuildEventContext?.TargetId > 0) { node = construction .GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId); if (Strings.IsTaskSkipped(message)) { messageNode.IsLowRelevance = true; } } else if (args.BuildEventContext?.ProjectContextId > 0) { var project = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId); node = project; if (Strings.IsTargetSkipped(message)) { var targetName = stringTable.Intern(TextUtilities.ParseQuotedSubstring(message)); if (targetName != null) { node = project.GetOrAddTargetByName(targetName); messageNode.IsLowRelevance = true; } } } else if (args.BuildEventContext.EvaluationId != -1) { var evaluation = construction.EvaluationFolder; var project = evaluation.FindChild <ProjectEvaluation>(p => p.Id == args.BuildEventContext.EvaluationId); node = project; if (node != null && node.FindChild <Message>(message) != null) { // avoid duplicate messages return; } } if (node == null) { node = construction.Build; if (Strings.IsEvaluationMessage(message)) { if (!evaluationMessagesAlreadySeen.Add(message)) { return; } node = construction.EvaluationFolder; } else if (Strings.IsTargetDoesNotExistAndWillBeSkipped(message)) { var folder = construction.EvaluationFolder; node = folder; messageNode.IsLowRelevance = true; } else if (args.BuildEventContext != null && (args.BuildEventContext.NodeId == 0 && args.BuildEventContext.ProjectContextId == 0 && args.BuildEventContext.ProjectInstanceId == 0 && args.BuildEventContext.TargetId == 0 && args.BuildEventContext.TaskId == 0)) { // must be Detailed Build Summary // https://github.com/Microsoft/msbuild/blob/master/src/XMakeBuildEngine/BackEnd/Components/Scheduler/Scheduler.cs#L509 DetailedSummary.AppendLine(message); return; } } node.AddChild(nodeToAdd); }
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; var 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; } if (!GetProjectItem(projectEntry, out var projectItem)) { projectEntry.IsInvalid = true; return; } BuildedProject buildedProject = BuildedProjects[projectItem]; var errorItem = new ErrorItem(errorLevel, (eI) => { _packageContext.GetDTE().Solution.GetProject(x => x.UniqueName == projectItem.UniqueName).NavigateToErrorItem(eI); }); switch (errorLevel) { case ErrorLevel.Message: Init(errorItem, (BuildMessageEventArgs)e); break; case ErrorLevel.Warning: Init(errorItem, (BuildWarningEventArgs)e); break; case ErrorLevel.Error: Init(errorItem, (BuildErrorEventArgs)e); break; default: throw new ArgumentOutOfRangeException("errorLevel"); } errorItem.VerifyValues(); buildedProject.ErrorsBox.Add(errorItem); OnErrorRaised(this, new BuildErrorRaisedEventArgs(errorLevel, buildedProject)); } catch (Exception ex) { ex.TraceUnknownException(); } }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="args">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs args, string message) { TreeNode parent = null; BaseNode nodeToAdd = null; bool lowRelevance = false; var buildEventContext = args.BuildEventContext; if (buildEventContext.TaskId > 0) { parent = GetTask(args); if (parent is Task task) { if (task is ResolveAssemblyReferenceTask rar) { if (ProcessRAR(rar, ref parent, message)) { return; } } else if (string.Equals(task.Name, "MSBuild", StringComparison.OrdinalIgnoreCase)) { if (ProcessMSBuildTask(task, ref parent, ref nodeToAdd, message)) { return; } } else if (string.Equals(task.Name, "RestoreTask", StringComparison.OrdinalIgnoreCase)) { if (ProcessRestoreTask(task, ref parent, message)) { return; } } else if (string.Equals(task.Name, "Mmp", StringComparison.OrdinalIgnoreCase)) { if (ProcessMmp(task, ref parent, message)) { return; } } } } else if (buildEventContext.TargetId > 0) { parent = GetTarget(args); if (Strings.TaskSkippedFalseConditionRegex.IsMatch(message)) { lowRelevance = true; } } else if (buildEventContext.ProjectContextId > 0) { var project = construction.GetOrAddProject(buildEventContext.ProjectContextId); parent = project; if (message.Equals("Building with tools version \"Current\".", StringComparison.Ordinal)) { // this is useless so just drop it on the floor return; } if (Strings.IsTargetSkipped(message)) { var targetName = Intern(TextUtilities.ParseQuotedSubstring(message)); if (targetName != null) { var skippedTarget = project.GetOrAddTargetByName(targetName, args.Timestamp); skippedTarget.StartTime = args.Timestamp; skippedTarget.EndTime = args.Timestamp; parent = skippedTarget; lowRelevance = true; } } } else if (buildEventContext.EvaluationId != -1) { parent = construction.EvaluationFolder; var evaluationId = buildEventContext.EvaluationId; var evaluation = construction.Build.FindEvaluation(evaluationId); if (evaluation != null) { parent = evaluation; } if (args is PropertyReassignmentEventArgs || Strings.PropertyReassignmentRegex.IsMatch(message)) { TimedNode properties; if (evaluation != null) { properties = evaluation.PropertyReassignmentFolder; } else { properties = parent.GetOrCreateNodeWithName <TimedNode>(Strings.PropertyReassignmentFolder, addAtBeginning: true); } var propertyName = Strings.GetPropertyName(message); parent = properties.GetOrCreateNodeWithName <Folder>(propertyName); } else if (parent == evaluation && parent.FindChild <Message>(message) != null) { // avoid duplicate messages return; } } if (parent == null) { parent = construction.Build; if (construction.Build.FileFormatVersion < 9 && Strings.IsEvaluationMessage(message)) { if (!evaluationMessagesAlreadySeen.Add(message)) { return; } parent = construction.EvaluationFolder; } else if (construction.Build.FileFormatVersion < 9 && Strings.PropertyReassignmentRegex.IsMatch(message)) { if (!evaluationMessagesAlreadySeen.Add(message)) { return; } var properties = construction.EvaluationFolder.GetOrCreateNodeWithName <Folder>(Strings.PropertyReassignmentFolder); parent = properties.GetOrCreateNodeWithName <Folder>(Strings.GetPropertyName(message)); } else if (Strings.IsTargetDoesNotExistAndWillBeSkipped(message)) { var folder = construction.EvaluationFolder; parent = folder; lowRelevance = true; } else if ( buildEventContext.NodeId == 0 && buildEventContext.ProjectContextId == 0 && buildEventContext.ProjectInstanceId == 0 && buildEventContext.TargetId == 0 && buildEventContext.TaskId == 0) { // must be Detailed Build Summary // https://github.com/Microsoft/msbuild/blob/master/src/XMakeBuildEngine/BackEnd/Components/Scheduler/Scheduler.cs#L509 DetailedSummary.AppendLine(message); return; } else if ( buildEventContext.NodeId == -2 && buildEventContext.ProjectContextId == -2 && buildEventContext.ProjectInstanceId == -1) { if (message.StartsWith(Strings.MSBuildVersionPrefix)) { var version = message.Substring(Strings.MSBuildVersionPrefix.Length); construction.Build.MSBuildVersion = version; } } } if (nodeToAdd == null) { message = Intern(message); nodeToAdd = new Message { Text = message, Timestamp = args.Timestamp, IsLowRelevance = lowRelevance }; } parent.AddChild(nodeToAdd); }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="args">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs args, string message) { TreeNode node = null; var messageNode = new Message { Text = stringTable.Intern(message), Timestamp = args.Timestamp }; if (args.BuildEventContext?.TaskId > 0) { node = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId) .GetTaskById(args.BuildEventContext.TaskId); var task = node as Task; if (task != null && task.Name == "ResolveAssemblyReference") { node = task.GetOrCreateNodeWithName <Folder>("Inputs"); if (message.StartsWith(" ")) { var parameter = node.FindLastChild <Parameter>(); if (parameter != null) { message = message.Substring(4); if (!string.IsNullOrWhiteSpace(message)) { parameter.AddChild(new Item() { Text = stringTable.Intern(message) }); } return; } } else { node = node.GetOrCreateNodeWithName <Parameter>(message.TrimEnd(':')); return; } } } else if (args.BuildEventContext?.TargetId > 0) { node = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId); if (message.StartsWith("Task") && message.Contains("skipped")) { messageNode.IsLowRelevance = true; } } else if (args.BuildEventContext?.ProjectContextId > 0) { var project = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId); node = project; if (message.StartsWith("Target") && message.Contains("skipped")) { var targetName = stringTable.Intern(ParseTargetName(message)); if (targetName != null) { node = project.GetOrAddTargetByName(targetName); messageNode.IsLowRelevance = true; } } } if (node == null) { node = construction.Build; if (message.StartsWith("Overriding target")) { var folder = construction.Build.GetOrCreateNodeWithName <Folder>("TargetOverrides"); folder.IsLowRelevance = true; node = folder; messageNode.IsLowRelevance = true; } else if (message.StartsWith("The target") && message.Contains("does not exist in the project, and will be ignored")) { var folder = construction.Build.GetOrCreateNodeWithName <Folder>("MissingTargets"); folder.IsLowRelevance = true; node = folder; messageNode.IsLowRelevance = true; } else if (args.BuildEventContext != null && (args.BuildEventContext.NodeId == 0 && args.BuildEventContext.ProjectContextId == 0 && args.BuildEventContext.ProjectInstanceId == 0 && args.BuildEventContext.TargetId == 0 && args.BuildEventContext.TaskId == 0)) { // must be Detailed Build Summary // https://github.com/Microsoft/msbuild/blob/master/src/XMakeBuildEngine/BackEnd/Components/Scheduler/Scheduler.cs#L509 node = construction.Build.GetOrCreateNodeWithName <Folder>("DetailedSummary"); } } node.AddChild(messageNode); }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="args">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs args, string message) { message = stringTable.Intern(message); TreeNode node = null; var messageNode = new Message { Text = message, Timestamp = args.Timestamp }; BaseNode nodeToAdd = messageNode; if (args.BuildEventContext?.TaskId > 0) { node = construction .GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId) .GetTaskById(args.BuildEventContext.TaskId); var task = node as Task; if (task != null) { if (task.Name == "ResolveAssemblyReference") { Folder inputs = task.GetOrCreateNodeWithName <Folder>("Inputs"); Folder results = task.FindChild <Folder>("Results"); node = results ?? inputs; if (message.StartsWith(" ")) { message = message.Substring(4); var parameter = node.FindLastChild <Parameter>(); if (parameter != null) { bool thereWasAConflict = Strings.IsThereWasAConflictPrefix(parameter.ToString()); //parameter.ToString().StartsWith(Strings.ThereWasAConflictPrefix); if (thereWasAConflict) { HandleThereWasAConflict(parameter, message, stringTable); return; } if (!string.IsNullOrWhiteSpace(message)) { node = parameter; if (message.StartsWith(" ")) { message = message.Substring(4); var lastItem = parameter.FindLastChild <Item>(); // only indent if it's not a "For SearchPath..." message - that one needs to be directly under parameter // also don't indent if it's under AssemblyFoldersEx in Results if (lastItem != null && !Strings.ForSearchPathPrefix.IsMatch(message) && !parameter.Name.StartsWith("AssemblyFoldersEx")) { node = lastItem; } } if (!string.IsNullOrEmpty(message)) { var equals = message.IndexOf('='); if (equals != -1) { var kvp = TextUtilities.ParseNameValue(message); node.AddChild(new Metadata { Name = stringTable.Intern(kvp.Key.TrimEnd(space)), Value = stringTable.Intern(kvp.Value.TrimStart(space)) }); } else { node.AddChild(new Item() { Text = stringTable.Intern(message) }); } } } return; } } else { if (results == null) { bool isResult = Strings.UnifiedPrimaryReferencePrefix.IsMatch(message) || Strings.PrimaryReferencePrefix.IsMatch(message) || Strings.DependencyPrefix.IsMatch(message) || Strings.UnifiedDependencyPrefix.IsMatch(message) || Strings.AssemblyFoldersExLocation.IsMatch(message) || Strings.IsThereWasAConflictPrefix(message); if (isResult) { results = task.GetOrCreateNodeWithName <Folder>("Results"); node = results; } else { node = inputs; } } else { node = results; } node.GetOrCreateNodeWithName <Parameter>(stringTable.Intern(message.TrimEnd(':'))); return; } } else if (string.Equals(task.Name, "MSBuild", StringComparison.OrdinalIgnoreCase)) { if (message.StartsWith(Strings.GlobalPropertiesPrefix) || Strings.AdditionalPropertiesPrefix.IsMatch(message) || Strings.OverridingGlobalPropertiesPrefix.IsMatch(message) || message.StartsWith(Strings.RemovingPropertiesPrefix) || Strings.RemovingProjectProperties.IsMatch(message)) { node.GetOrCreateNodeWithName <Folder>(message); return; } node = node.FindLastChild <Folder>() ?? node; if (message.Length > 2 && message[0] == ' ' && message[1] == ' ') { message = message.Substring(2); } var kvp = TextUtilities.ParseNameValue(message); if (kvp.Value == "") { nodeToAdd = new Item { Text = stringTable.Intern(kvp.Key) }; } else { nodeToAdd = new Property { Name = stringTable.Intern(kvp.Key), Value = stringTable.Intern(kvp.Value) }; } } else if (string.Equals(task.Name, "RestoreTask")) { // just throw these away to save space // https://github.com/NuGet/Home/issues/10383 if (message.StartsWith(Strings.RestoreTask_CheckingCompatibilityFor)) { return; } else if (message.StartsWith(" GET")) { node = node.GetOrCreateNodeWithName <Folder>("GET"); } else if (message.StartsWith(" CACHE")) { node = node.GetOrCreateNodeWithName <Folder>("CACHE"); } else if (message.StartsWith(" OK")) { node = node.GetOrCreateNodeWithName <Folder>("OK"); } else if (message.StartsWith(" NotFound")) { node = node.GetOrCreateNodeWithName <Folder>("NotFound"); } else if ( message.StartsWith(Strings.RestoreTask_CheckingCompatibilityFor) || message.StartsWith(Strings.RestoreTask_CheckingCompatibilityOfPackages) || message.StartsWith(Strings.RestoreTask_AcquiringLockForTheInstallation) || message.StartsWith(Strings.RestoreTask_AcquiredLockForTheInstallation) || message.StartsWith(Strings.RestoreTask_CompletedInstallationOf) || message.StartsWith(Strings.RestoreTask_ResolvingConflictsFor) ) { return; } } } } else if (args.BuildEventContext?.TargetId > 0) { node = construction .GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId); if (Strings.TaskSkippedFalseCondition.Match(message).Success) { messageNode.IsLowRelevance = true; } } else if (args.BuildEventContext?.ProjectContextId > 0) { var project = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId); node = project; if (Strings.IsTargetSkipped(message)) { var targetName = stringTable.Intern(TextUtilities.ParseQuotedSubstring(message)); if (targetName != null) { var skippedTarget = project.GetOrAddTargetByName(targetName, args.Timestamp); skippedTarget.StartTime = args.Timestamp; skippedTarget.EndTime = args.Timestamp; node = skippedTarget; messageNode.IsLowRelevance = true; } } } else if (args.BuildEventContext.EvaluationId != -1) { node = construction.EvaluationFolder; var project = node.FindChild <ProjectEvaluation>(p => p.Id == args.BuildEventContext.EvaluationId); if (project != null) { node = project; } if (Strings.PropertyReassignment.IsMatch(message)) { var properties = node.GetOrCreateNodeWithName <Folder>(Strings.Properties, true); node = properties.GetOrCreateNodeWithName <Folder>(Strings.GetPropertyName(message)); } if (node != null && node.FindChild <Message>(message) != null) { // avoid duplicate messages return; } } if (node == null) { node = construction.Build; if (Strings.IsEvaluationMessage(message)) { if (!evaluationMessagesAlreadySeen.Add(message)) { return; } node = construction.EvaluationFolder; } else if (Strings.PropertyReassignment.IsMatch(message)) { if (!evaluationMessagesAlreadySeen.Add(message)) { return; } var properties = construction.EvaluationFolder.GetOrCreateNodeWithName <Folder>(Strings.Properties); node = properties.GetOrCreateNodeWithName <Folder>(Strings.GetPropertyName(message)); } else if (Strings.IsTargetDoesNotExistAndWillBeSkipped(message)) { var folder = construction.EvaluationFolder; node = folder; messageNode.IsLowRelevance = true; } else if (args.BuildEventContext != null && (args.BuildEventContext.NodeId == 0 && args.BuildEventContext.ProjectContextId == 0 && args.BuildEventContext.ProjectInstanceId == 0 && args.BuildEventContext.TargetId == 0 && args.BuildEventContext.TaskId == 0)) { // must be Detailed Build Summary // https://github.com/Microsoft/msbuild/blob/master/src/XMakeBuildEngine/BackEnd/Components/Scheduler/Scheduler.cs#L509 DetailedSummary.AppendLine(message); return; } } node.AddChild(nodeToAdd); }
private static string FormatMessage(LazyFormattedBuildEventArgs e) { return(string.Format("{0}:{1}$$", e.HelpKeyword, e.Message)); }
/// <summary> /// Handles a generic BuildMessage event and assigns it to the appropriate logging node. /// </summary> /// <param name="args">The <see cref="BuildMessageEventArgs"/> instance containing the event data.</param> public void AddMessage(LazyFormattedBuildEventArgs args, string message) { TreeNode node = null; var messageNode = new Message { Text = stringTable.Intern(message), Timestamp = args.Timestamp }; if (args.BuildEventContext?.TaskId > 0) { node = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId) .GetTaskById(args.BuildEventContext.TaskId); var task = node as Task; if (task != null && task.Name == "ResolveAssemblyReference") { Folder inputs = task.GetOrCreateNodeWithName <Folder>("Inputs"); Folder results = task.FindChild <Folder>(c => c.Name == "Results"); node = results ?? inputs; if (message.StartsWith(" ")) { message = message.Substring(4); var parameter = node.FindLastChild <Parameter>(); if (parameter != null) { if (!string.IsNullOrWhiteSpace(message)) { node = parameter; if (message.StartsWith(" ")) { message = message.Substring(4); var lastItem = parameter.FindLastChild <Item>(); // only indent if it's not a "For SearchPath..." message - that one needs to be directly under parameter if (lastItem != null && !message.StartsWith("For SearchPath")) { node = lastItem; } } if (!string.IsNullOrEmpty(message)) { node.AddChild(new Item() { Text = stringTable.Intern(message) }); } } return; } } else { if (results == null) { bool isResult = message.StartsWith("Unified primary reference ") || message.StartsWith("Primary reference ") || message.StartsWith("Dependency ") || message.StartsWith("Unified Dependency "); if (isResult) { results = task.GetOrCreateNodeWithName <Folder>("Results"); node = results; } else { node = inputs; } } else { node = results; } node.GetOrCreateNodeWithName <Parameter>(message.TrimEnd(':')); return; } } } else if (args.BuildEventContext?.TargetId > 0) { node = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId) .GetTargetById(args.BuildEventContext.TargetId); if (message.StartsWith("Task") && message.Contains("skipped")) { messageNode.IsLowRelevance = true; } } else if (args.BuildEventContext?.ProjectContextId > 0) { var project = construction.GetOrAddProject(args.BuildEventContext.ProjectContextId); node = project; if (message.StartsWith("Target") && message.Contains("skipped")) { var targetName = stringTable.Intern(ParseTargetName(message)); if (targetName != null) { node = project.GetOrAddTargetByName(targetName); messageNode.IsLowRelevance = true; } } } if (node == null) { node = construction.Build; if (message.StartsWith("Overriding target")) { var folder = construction.Build.GetOrCreateNodeWithName <Folder>("TargetOverrides"); folder.IsLowRelevance = true; node = folder; messageNode.IsLowRelevance = true; } else if (message.StartsWith("The target") && message.Contains("does not exist in the project, and will be ignored")) { var folder = construction.Build.GetOrCreateNodeWithName <Folder>("MissingTargets"); folder.IsLowRelevance = true; node = folder; messageNode.IsLowRelevance = true; } else if (args.BuildEventContext != null && (args.BuildEventContext.NodeId == 0 && args.BuildEventContext.ProjectContextId == 0 && args.BuildEventContext.ProjectInstanceId == 0 && args.BuildEventContext.TargetId == 0 && args.BuildEventContext.TaskId == 0)) { // must be Detailed Build Summary // https://github.com/Microsoft/msbuild/blob/master/src/XMakeBuildEngine/BackEnd/Components/Scheduler/Scheduler.cs#L509 node = construction.Build.GetOrCreateNodeWithName <Folder>("DetailedSummary"); } } node.AddChild(messageNode); }