Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missed errors appearance on restore #9424

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/MSBuild/TerminalLogger/TerminalLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,28 +635,38 @@ private bool IsImmediateMessage(string message)
/// </summary>
private void ErrorRaised(object sender, BuildErrorEventArgs e)
{
var buildEventContext = e.BuildEventContext;
if (buildEventContext is not null && _projects.TryGetValue(new ProjectContext(buildEventContext), out Project? project))
{
string message = EventArgsFormatting.FormatEventMessage(
BuildEventContext? buildEventContext = e.BuildEventContext;
Project? project = null;
bool isTrackedProject = buildEventContext is not null && _projects.TryGetValue(new ProjectContext(buildEventContext), out project);
string message = EventArgsFormatting.FormatEventMessage(
category: AnsiCodes.Colorize("error", TerminalColor.Red),
subcategory: e.Subcategory,
message: e.Message,
code: AnsiCodes.Colorize(e.Code, TerminalColor.Red),
file: HighlightFileName(e.File),
projectFile: null,

// for the tracked projects the project file name is included in the final output result.
projectFile: isTrackedProject ? null : e.ProjectFile ?? string.Empty,
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
lineNumber: e.LineNumber,
endLineNumber: e.EndLineNumber,
columnNumber: e.ColumnNumber,
endColumnNumber: e.EndColumnNumber,
threadId: e.ThreadId,
logOutputProperties: null);

project.AddBuildMessage(MessageSeverity.Error, message);
if (isTrackedProject)
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
{
project!.AddBuildMessage(MessageSeverity.Error, message);
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
}

// It is necessary to display error messages reported by MSBuild, even if it's not tracked in _projects collection.
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
else
{
RenderImmediateMessage(message);
ladipro marked this conversation as resolved.
Show resolved Hide resolved
}
}

#endregion
#endregion

#region Refresher thread implementation

Expand Down