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

Restore error summary #12522

Open
aelij opened this issue Apr 4, 2023 · 0 comments
Open

Restore error summary #12522

aelij opened this issue Apr 4, 2023 · 0 comments
Labels
Area:Logging Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Feature

Comments

@aelij
Copy link

aelij commented Apr 4, 2023

NuGet Product(s) Involved

MSBuild.exe, dotnet.exe

The Elevator Pitch

When updating a very large legacy monorepo to SDK-style projects, NuGet restore spewed out thousands of errors. It was difficult to browse through all the text and identify the root causes. I created a small summary tool using the binlog parser and regex error message grouping (which removed project-specific text), and it proved most helpful:

#r "nuget: MSBuild.StructuredLogger, 2.1.790"
using Microsoft.Build.Logging.StructuredLogger;

var log = BinaryLog.ReadBuild(@"msbuild.binlog");
var errors = log.FindChildrenRecursive<Error>().DumpAs(t => t.Count);
errors.GroupBy(c => c.Code).Select(c => (code: c.Key, messages: c.GroupBy(m => ResolveText(c.Key, m.Text), m => m.File))).Dump();

static string ResolveText(string code, string text) => code switch
	{
		"NU1602" => Regex.Match(text, @"for dependency ([-\w\.]+)\.").Value,
		"NU1605" or "NU1109" => Regex.Match(text, @"Detected package downgrade: ([-\w\.]+) from ([-\w\.]+) to (centrally defined)? ([-\w\.]+)").Value,
		"NU1603" => Regex.Match(text, @"([-\w\.]+) ([-\w\.]+) depends on ([-\w\.]+) \(>= ([-\w\.]+)\)").Value,
		_ => text
	};

The output looks something like this:

- NU1202
  - Package x.y 1.2.3 is not compatible with ...
    - path/to/p1.csproj
    - path/to/p2.csproj
  - Package a.b 3.4.5 is not compatible with ...
    - path/to/p3.csproj
- NU1605
  - Detected package downgrade: x.y ...
    - path/to/p4.csproj

I propose that the restore target of a root traversal project optionally emit such a text summary at the end. For error grouping, perhaps use the ShortenedText property and remove project-specific data from it.

Additional Context and Details

No response

@jeffkl jeffkl added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Pipeline:Icebox and removed Type:DCR Design Change Request labels Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Logging Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Feature
Projects
None yet
Development

No branches or pull requests

3 participants