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

Improve the "Undefined" value in the Code column of the Error List of Visual Studio to know that a warning comes from NuGet #14070

Open
carlos-quintero opened this issue Jan 27, 2025 · 0 comments
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Area:Protocol Client/Server protocol /code around it Triage:NeedsTriageDiscussion Type:DCR Design Change Request

Comments

@carlos-quintero
Copy link

carlos-quintero commented Jan 27, 2025

NuGet Product(s) Affected

MSBuild.exe

Current Behavior

Warnings emitted by the "x-nuget-warning" header (specs: https://github.com/NuGet/Home/wiki/%5BSpec%5D-Server-side-warnings-for-NuGet-client) don't have a NuGet code, so the NuGetLogCode.Undefined = 0 value (https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs) is used and they can appear in the Error List of Visual Studio like so for this example of "No Authorization header detected":

Image

Notice that nothing in the Error List says where this warning comes from. You can spend hours until you discover that they come from a NuGet server (GitHub, in my case).

Desired Behavior

It would be nice that NuGet servers such as GitHub provide a better description (such as "No Authorization header was detected in the request to GitHub") but since that is a server-side issue, there is nothing that you can do. But you can do something about the "Undefined" literal, changing it to "Undefined NuGet code", and therefore at least you know that the error comes from a NuGet operation. I think that it is these lines: https://github.com/dotnet/sdk/blob/63f75ac549d6218da1dd6c459d53e20cbf20459e/src/Tasks/Microsoft.NET.Build.Tasks/LockFileCache.cs#L121C1-L126C49. I think it would be enough to use error code NuGetLogCode.NU1000 (which means "undefined" NuGet error and would appear in the Code column of the Error List as NU1000, and you would know that is a NuGet error) instead of NuGetLogCode.Undefined (which appears in the Code column as "Undefined" and you cannot know that is a NuGet error)

Additional Context

When you use a command-line NuGet client you know that you are executing NuGet commands, but in this case it's Visual Studio who is executing NuGet commands (that don't appear in the Output window) and you don't know. In this case I think Visual Studio is executing the NuGet Audit API because the warning appears just after loading a solution, but I can't know for sure.

@martinrrm martinrrm added Triage:NeedsTriageDiscussion Area:ErrorHandling warnings and errors/log messages & related error codes. Area:Protocol Client/Server protocol /code around it and removed Triage:Untriaged labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:ErrorHandling warnings and errors/log messages & related error codes. Area:Protocol Client/Server protocol /code around it Triage:NeedsTriageDiscussion Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

2 participants