-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
dotnet package list
command should restore first
#47873
base: main
Are you sure you want to change the base?
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
|
||
if (formatOption == ReportOutputFormat.json) | ||
{ | ||
args = ["-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.
tiny nit: -target:Restore
{ | ||
string jsonError = $$""" | ||
{ | ||
"version": 1, |
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.
What version is this?
string jsonError = $$""" | ||
{ | ||
"version": 1, | ||
"problems": [ |
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.
"errors"? Or since this doesn't really seem to be an array, can we just make it "error" and have it be the object?
] | ||
} | ||
"""; | ||
Console.WriteLine(jsonError); |
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.
This feels like it should go elsewhere. Does NuGet normally just write to the console? Seems like there should be some kind of logger, or at least this should go to Console.Error
@@ -174,4 +174,11 @@ | |||
<data name="CmdOutputVersionDescription" xml:space="preserve"> | |||
<value>Specifies the version of machine-readable output. Requires the '--format json' option.</value> | |||
</data> | |||
<data name="Error_restore" xml:space="preserve"> | |||
<value>Restore failed. Run `dotnet restore` for more details on the issue.</value> | |||
<comment>Do not translate `dotnet restore`</comment> |
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: use the locking syntax for pinned translation strings so that the Loc team's tooling helps prevent unintentional translation.
} | ||
|
||
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.
I was looking this and comparing it with RestoringCommand. I'm not entirely sure why they look so different. This looks correct, as far as I can tell; I just thought it'd would be nice to combine them if possible.
#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
