Skip to content

Commit c2f4ba2

Browse files
committed
Add configuration for non interactive mode
1 parent 12a8d69 commit c2f4ba2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Cake.NuGet/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public static class NuGet
2727
/// The config key name for overriding the default NuGet config file.
2828
/// </summary>
2929
public const string ConfigFile = "NuGet_ConfigFile";
30+
31+
/// <summary>
32+
/// The config key name for non-interactive mode.
33+
/// </summary>
34+
public const string NonInteractive = "NuGet_NonInteractive";
3035
}
3136

3237
public static class Paths

src/Cake.NuGet/Installers/InProcessInstaller.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ public IReadOnlyCollection<IFile> Install(PackageReference package, PackageType
115115
allRepositories.AddRange(localAndPrimaryRepositories);
116116
allRepositories.AddRange(sourceRepositoryProvider.Repositories);
117117

118-
DefaultCredentialServiceUtility.SetupDefaultCredentialService(_nugetLogger, true);
118+
var nonInteractiveString = _config.GetValue(Constants.NuGet.NonInteractive) ?? bool.TrueString;
119+
if (!bool.TryParse(nonInteractiveString, out bool nonInteractive))
120+
{
121+
// If there is no explicit preference, use non interactive.
122+
nonInteractive = true;
123+
}
124+
DefaultCredentialServiceUtility.SetupDefaultCredentialService(_nugetLogger, nonInteractive);
119125

120126
var packageIdentity = GetPackageId(package, localAndPrimaryRepositories, targetFramework, _sourceCacheContext, _nugetLogger);
121127
if (packageIdentity == null)

0 commit comments

Comments
 (0)