NuGet/Home

`dotnet add package` is too verbose

Open

#12,548 建立於 2023年4月21日

在 GitHub 查看
 (9 留言) (7 反應) (0 負責人)HTML (1,459 star) (292 fork)batch import
Area:LoggingCategory:Quality WeekPriority:2Product:dotnet.exeType:DCRhelp wanted

描述

NuGet Product(s) Affected

dotnet.exe

Current Behavior

This is the default experience for dotnet add package.

% dotnet add package spectre.console
  Determining projects to restore...
  Writing /var/folders/g5/4rfd120s6bg5b3nj03bryglr0000gn/T/tmpQAjnQA.tmp
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/local/share/dotnet/sdk/8.0.100-preview.3.23178.7/trustedroots/codesignctl.pem'.
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/local/share/dotnet/sdk/8.0.100-preview.3.23178.7/trustedroots/timestampctl.pem'.
info : Adding PackageReference for package 'spectre.console' into project '/Users/rich/git/font/LedMatrix/samples/Matrix.samples.csproj'.
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/index.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/index.json 82ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.0.1/0.19.0.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.0.1/0.19.0.json 82ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.19.1-preview.0.1/0.32.1.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.19.1-preview.0.1/0.32.1.json 81ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.32.2-preview.0.1/0.37.1-preview.0.38.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.32.2-preview.0.1/0.37.1-preview.0.38.json 84ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.37.1-preview.0.39/0.40.1-preview.0.8.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.37.1-preview.0.39/0.40.1-preview.0.8.json 83ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.40.1-preview.0.9/0.43.1-preview.0.41.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.40.1-preview.0.9/0.43.1-preview.0.41.json 87ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.43.1-preview.0.42/0.45.1-preview.0.49.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.43.1-preview.0.42/0.45.1-preview.0.49.json 85ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.45.1-preview.0.51/0.46.1-preview.0.20.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/spectre.console/page/0.45.1-preview.0.51/0.46.1-preview.0.20.json 80ms
info : Restoring packages for /Users/rich/git/font/LedMatrix/samples/Matrix.samples.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/spectre.console/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/spectre.console/index.json 84ms
info :   GET https://api.nuget.org/v3-flatcontainer/spectre.console/0.46.0/spectre.console.0.46.0.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/spectre.console/0.46.0/spectre.console.0.46.0.nupkg 120ms
info : Installed Spectre.Console 0.46.0 from https://api.nuget.org/v3/index.json with content hash qd2OMEGxfQW1KLuQj56KKHkIK6eB/IUF/AET5CRl/efROHGsvBehx9shfkL0HgJEHLCwRiR7foWi4/LkdPk18g==.
info : Package 'spectre.console' is compatible with all the specified frameworks in project '/Users/rich/git/font/LedMatrix/samples/Matrix.samples.csproj'.
info : PackageReference for package 'spectre.console' version '0.46.0' added to file '/Users/rich/git/font/LedMatrix/samples/Matrix.samples.csproj'.
info : Writing assets file to disk. Path: /Users/rich/git/font/LedMatrix/samples/obj/project.assets.json
log  : Restored /Users/rich/git/font/LedMatrix/samples/Matrix.samples.csproj (in 1.78 sec).

This looks like excellent output for "verbose mode". I am wondering why this is the default experience since there is no call to action from this information in the success case. We should aim to simplify UX. This flow is presumably popular enough that we should seek to improve it.

I don't believe that there is another experience in the product that has this same level of console output.

Here is a nice counterexample, doing something very similar.

% dotnet tool install -g dotnet-runtimeinfo  
Skipping NuGet package signature verification.
You can invoke the tool using the following command: dotnet-runtimeinfo
Tool 'dotnet-runtimeinfo' (version '1.0.5') was successfully installed.

Also, there isn't an obvious way to control verbosity.

% dotnet add package --help         
Description:
  Add a NuGet package reference to the project.

Usage:
  dotnet add [<PROJECT>] package <PACKAGE_NAME> [options]

Arguments:
  <PROJECT>       The project file to operate on. If a file is not specified, 
                  the command will search the current directory for one. 
                  [default: /Users/rich/git/font/LedMatrix/samples/]
  <PACKAGE_NAME>  The package reference to add.

Options:
  -v, --version <VERSION>            The version of the package to add.
  -f, --framework <FRAMEWORK>        Add the reference only when targeting a 
                                     specific framework.
  -n, --no-restore                   Add the reference without performing 
                                     restore preview and compatibility check.
  -s, --source <SOURCE>              The NuGet package source to use during the 
                                     restore.
  --package-directory <PACKAGE_DIR>  The directory to restore packages to.
  --interactive                      Allows the command to stop and wait for 
                                     user input or action (for example to 
                                     complete authentication).
  --prerelease                       Allows prerelease packages to be installed.
  -?, -h, --help                     Show command line help.

Desired Behavior

Provide output that is useful for the scenario.

Additional Context

https://github.com/dotnet/sdk/issues/31946

貢獻者指南