diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 018f4718ae9f..01a6dcb2dadf 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -698,6 +698,7 @@ bool TryGetPackageMetadata( try { SourceRepository repository = GetSourceRepository(source); + DefaultCredentialServiceUtility.SetupDefaultCredentialService(new NuGetConsoleLogger(), !_restoreActionConfig.Interactive); PackageMetadataResource resource = await repository .GetResourceAsync(cancellationToken).ConfigureAwait(false); diff --git a/src/Cli/dotnet/commands/dotnet-tool/restore/ToolRestoreCommand.cs b/src/Cli/dotnet/commands/dotnet-tool/restore/ToolRestoreCommand.cs index da758096dd70..87215e4fb9e9 100644 --- a/src/Cli/dotnet/commands/dotnet-tool/restore/ToolRestoreCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-tool/restore/ToolRestoreCommand.cs @@ -3,6 +3,7 @@ using System.CommandLine; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.DotNet.Cli.ToolPackage; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ToolManifest; @@ -24,6 +25,7 @@ internal class ToolRestoreCommand : CommandBase private readonly string[] _sources; private readonly IToolPackageDownloader _toolPackageDownloader; private readonly VerbosityOptions _verbosity; + private readonly RestoreActionConfig _restoreActionConfig; public ToolRestoreCommand( ParseResult result, @@ -61,6 +63,15 @@ public ToolRestoreCommand( _configFilePath = result.GetValue(ToolRestoreCommandParser.ConfigOption); _sources = result.GetValue(ToolRestoreCommandParser.AddSourceOption); _verbosity = result.GetValue(ToolRestoreCommandParser.VerbosityOption); + if (!result.HasOption(ToolRestoreCommandParser.VerbosityOption) && result.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption)) + { + _verbosity = VerbosityOptions.minimal; + } + + _restoreActionConfig = new RestoreActionConfig(DisableParallel: result.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption), + NoCache: result.GetValue(ToolCommandRestorePassThroughOptions.NoCacheOption) || result.GetValue(ToolCommandRestorePassThroughOptions.NoHttpCacheOption), + IgnoreFailedSources: result.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption), + Interactive: result.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption)); } public override int Execute() @@ -130,7 +141,11 @@ private ToolRestoreResult InstallPackages( nugetConfig: configFile, additionalFeeds: _sources, rootConfigDirectory: package.FirstEffectDirectory), - package.PackageId, verbosity: _verbosity, ToVersionRangeWithOnlyOneVersion(package.Version), targetFramework + package.PackageId, + verbosity: _verbosity, + ToVersionRangeWithOnlyOneVersion(package.Version), + targetFramework, + restoreActionConfig: _restoreActionConfig ); if (!ManifestCommandMatchesActualInPackage(package.CommandNames, [toolPackage.Command]))