-
Notifications
You must be signed in to change notification settings - Fork 701
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 MSBuild restore is logging exception as warning #4248
Conversation
test/NuGet.Core.FuncTests/Msbuild.Integration.Test/MsbuildRestoreTaskTests.cs
Show resolved
Hide resolved
19ebe4e
to
1ce0fb3
Compare
1ce0fb3
to
18b9e20
Compare
@@ -480,7 +480,8 @@ private NuGetPackageManager GetNuGetPackageManager(string solutionDirectory) | |||
{ | |||
if (!string.IsNullOrEmpty(exception.Message)) | |||
{ | |||
nuGetProjectContext.Log(MessageLevel.Warning, exception.Message); | |||
var errorMessage = string.Format(Strings.RestoreErrorNU1000, exception.Message); | |||
nuGetProjectContext.Log(MessageLevel.Error, errorMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should need to format the NU code into the message yourself. If you look at how other warnings/errors are created, we have helper methods. For example:
await _logger.LogAsync(RestoreLogMessage.CreateError(NuGetLogCode.NU1011, Strings.Error_CentralPackageVersions_FloatingVersionsAreNotAllowed)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zivkan
Thank you for your suggestion. I used the helper method.
18b9e20
to
ef4ead3
Compare
test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetRestoreCommandTest.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetInstallCommandTest.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetInstallCommandTest.cs
Outdated
Show resolved
Hide resolved
@NuGet/nuget-client |
@@ -480,7 +480,7 @@ private NuGetPackageManager GetNuGetPackageManager(string solutionDirectory) | |||
{ | |||
if (!string.IsNullOrEmpty(exception.Message)) | |||
{ | |||
nuGetProjectContext.Log(MessageLevel.Warning, exception.Message); | |||
nuGetProjectContext.Log(RestoreLogMessage.CreateError(NuGetLogCode.NU1000, exception.Message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is NU1000 redundant?
Isn't that the default anyways, so wouldn't:
nuGetProjectContext.Log(MessageLevel.Error, exception.Message);
be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that addresses my concern.
Isn't NU1000 the default code? The tests seem to suggest that as well.
packages.config doesn't really have specific error codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's default code. But since we don't have specific error code opted to use generic NU1000.
Do you suggest removing any NU code from here? So we can just keep error part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah my suggestion was to remove it. Codes are just not a thing in packages.config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I addressed your comment. Please review again.
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
Bug
Fixes: NuGet/Home#11179
Regression? Last working version:
Description
While debugging test I noticed some exceptions in msbuild restore task logging exception message as warning, I believe it should log as error instead.
Before no error, yet a failure return code is not fixed. Also just in case added unit test to assert same issue doesn't exist for nuget.exe.
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation