diff --git a/src/Cake.NuGet/Cake.NuGet.csproj b/src/Cake.NuGet/Cake.NuGet.csproj index 0982262f7e..20c73d971f 100644 --- a/src/Cake.NuGet/Cake.NuGet.csproj +++ b/src/Cake.NuGet/Cake.NuGet.csproj @@ -18,6 +18,7 @@ + diff --git a/src/Cake.NuGet/Client/NuGetLogger.cs b/src/Cake.NuGet/Client/NuGetLogger.cs index df1fea36dd..6eb03bcebc 100644 --- a/src/Cake.NuGet/Client/NuGetLogger.cs +++ b/src/Cake.NuGet/Client/NuGetLogger.cs @@ -50,23 +50,23 @@ public NuGetLogger(ICakeLog log) _log = log ?? throw new ArgumentNullException(nameof(log)); } - public void LogDebug(string data) => _log.Debug(data); + public void LogDebug(string data) => _log.Debug("{0}", data); - public void LogVerbose(string data) => _log.Debug(data); + public void LogVerbose(string data) => _log.Debug("{0}", data); - public void LogInformation(string data) => _log.Debug(data); + public void LogInformation(string data) => _log.Debug("{0}", data); - public void LogMinimal(string data) => _log.Information(data); + public void LogMinimal(string data) => _log.Information("{0}", data); - public void LogWarning(string data) => _log.Warning(data); + public void LogWarning(string data) => _log.Warning("{0}", data); - public void LogError(string data) => _log.Error(data); + public void LogError(string data) => _log.Error("{0}", data); - public void LogInformationSummary(string data) => _log.Information(data); + public void LogInformationSummary(string data) => _log.Information("{0}", data); - public void LogErrorSummary(string data) => _log.Error(data); + public void LogErrorSummary(string data) => _log.Error("{0}", data); - public void Log(LogLevel level, string data) => _log.Write(GetVerbosity(level), GetLogLevel(level), data); + public void Log(LogLevel level, string data) => _log.Write(GetVerbosity(level), GetLogLevel(level), "{0}", data); public Task LogAsync(LogLevel level, string data) { diff --git a/src/Cake.NuGet/Constants.cs b/src/Cake.NuGet/Constants.cs index 9caccb2d83..f1f1a37a85 100644 --- a/src/Cake.NuGet/Constants.cs +++ b/src/Cake.NuGet/Constants.cs @@ -27,6 +27,11 @@ public static class NuGet /// The config key name for overriding the default NuGet config file. /// public const string ConfigFile = "NuGet_ConfigFile"; + + /// + /// The config key name for non-interactive mode. + /// + public const string NonInteractive = "NuGet_NonInteractive"; } public static class Paths diff --git a/src/Cake.NuGet/Installers/InProcessInstaller.cs b/src/Cake.NuGet/Installers/InProcessInstaller.cs index 5af290c13c..1c88c8f1b9 100644 --- a/src/Cake.NuGet/Installers/InProcessInstaller.cs +++ b/src/Cake.NuGet/Installers/InProcessInstaller.cs @@ -12,6 +12,7 @@ using Cake.Core.IO; using NuGet.Common; using NuGet.Configuration; +using NuGet.Credentials; using NuGet.Frameworks; using NuGet.Packaging; using NuGet.Packaging.Core; @@ -114,6 +115,14 @@ public IReadOnlyCollection Install(PackageReference package, PackageType allRepositories.AddRange(localAndPrimaryRepositories); allRepositories.AddRange(sourceRepositoryProvider.Repositories); + var nonInteractiveString = _config.GetValue(Constants.NuGet.NonInteractive) ?? bool.TrueString; + if (!bool.TryParse(nonInteractiveString, out bool nonInteractive)) + { + // If there is no explicit preference, use non interactive. + nonInteractive = true; + } + DefaultCredentialServiceUtility.SetupDefaultCredentialService(_nugetLogger, nonInteractive); + var packageIdentity = GetPackageId(package, localAndPrimaryRepositories, targetFramework, _sourceCacheContext, _nugetLogger); if (packageIdentity == null) { diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 7aa22af9db..8a58840333 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -21,6 +21,7 @@ + @@ -56,4 +57,4 @@ - + \ No newline at end of file