-
Notifications
You must be signed in to change notification settings - Fork 1.1k
dotnet package list
command should restore first
#47873
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
Conversation
src/Cli/dotnet/commands/Package/list/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
5ff051a
to
a8235d6
Compare
|
||
private int RunRestore(string projectOrSolution, ReportOutputFormat formatOption) | ||
{ | ||
MSBuildForwardingApp restoringCommand = new MSBuildForwardingApp(argsToForward: ["-target:restore", projectOrSolution, "-noConsoleLogger"]); |
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.
Since the implicit restore isn't logging anything, what if its takes more than a few seconds? I think the user might think something is wrong. We could pass console logger parameters to produce some output
-consoleLoggerParameters:Verbosity=Minimal;NoSummary
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.
We should try to align with test and run here and use the same logger configuration - ideally this would use terminal logger by default like every other command in the CLI.
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'm not so sure, the output of this command is the information about the packages that a project is referencing. Its not running tests (which are potentially long running) and its not building a project and its dependencies.
The only reason we need to run restore first is because the project.assets.json
file provides all of the information and we want to make sure its up-to-date. The only reason I propose we have any output at all about restore is in the case that it takes a while, I don't want users to think that dotnet list package
is hung.
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
review request: @dotnet/nuget-team any suggestions/comments? The more time this takes the more conflicts keep coming up |
: restoreExitCode; | ||
} | ||
|
||
private int RunRestore(string projectOrSolution, ReportOutputFormat formatOption, bool interactive) |
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.
Nit: This method does a lot of things to prepare the command to run. Consider adding private helper methods to set up the options and generate the json output and call them from this method.
<data name="Error_restore" xml:space="preserve"> | ||
<value>Restore failed. Run `dotnet restore` for more details on the issue.</value> |
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.
Question: Is this wording consistent with other output or was this wording vetted?
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.
On that note, why can't we output the error from dotnet restore without them having to run dotnet restore explicitly?
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.
Question: Is this wording consistent with other output or was this wording vetted?
This the first adoption of implicit restore for nuget commands. Others like dotnet nuget why will probably follow suit as well.
On that note, why can't we output the error from dotnet restore without them having to run dotnet restore explicitly?
When the command includes --format json
, we avoid printing any additional output to ensure the JSON remains valid. To enforce this, I passed -noConsoleLogger
to MSBuild. Since this operation runs in a separate process, capturing and displaying errors becomes tricky. If we were running the restore in-process, however, we could have easily captured the errors and logged them ourselves.
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 actually think this is a perfectly valid response, but I'll bang this drum on baronfel's behalf:
Output should go to stdout. Errors (and other incidental output) should go to stderr. That way you can have beautiful, clean output in stdout and still have access to all the information you'd want in stderr.
I'm assuming NuGet doesn't do that historically, so you're sending errors to stdout as well just because that's how it currently works?
Though if you're going to get an error anyway, does the user really still care that the output of --format json is preserved?
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.
That is good point! Tracking here now NuGet/Home#14239
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
src/Cli/dotnet/Commands/Package/List/ListPackageReferencesCommand.cs
Outdated
Show resolved
Hide resolved
@Nigusu-Allehu there are a bunch of conflicts to resolve fyi. |
a443cdd
to
c5f737f
Compare
@Nigusu-Allehu: Added When you commit this breaking change:
You can refer to the .NET SDK breaking change guidelines |
breaking change doc: dotnet/docs#46103 |
#47400 had to many conflicts.
Fixes: NuGet/Home#13406
Description
This PR
dotnet package list
command ordotnet list package
(Switch verb and noun for package/reference add/remove/list Fixes #9650 #45384)ScreenShots
package list --project [project]
--format json

restore error

restore error: --format json
