Skip to content
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

GH2345: Add NonInteractive property to NuGetRestoreSettings #2451

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public void Should_Set_RequireConsent_To_False_By_Default()
// Then
Assert.False(settings.RequireConsent);
}

[Fact]
public void Should_Set_NonInteractive_To_True_By_Default()
{
// Given, When
var settings = new NuGetRestoreSettings();

// Then
Assert.True(settings.NonInteractive);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ public void Should_Add_DisableParallelProcessing_To_Arguments_If_Set()
"-NonInteractive", result.Args);
}

[Fact]
public void Should_Remove_NonInteractive_From_Arguments_If_False()
{
// Given
var fixture = new NuGetRestorerFixture();
fixture.Settings.NonInteractive = false;

// When
var result = fixture.Run();

// Then
Assert.Equal("restore \"/Working/project.sln\"", result.Args);
}

[Theory]
[InlineData(NuGetVerbosity.Detailed, "restore \"/Working/project.sln\" -Verbosity detailed -NonInteractive")]
[InlineData(NuGetVerbosity.Normal, "restore \"/Working/project.sln\" -Verbosity normal -NonInteractive")]
Expand Down
6 changes: 5 additions & 1 deletion src/Cake.Common/Tools/NuGet/Restore/NuGetRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ private ProcessArgumentBuilder GetArguments(FilePath targetFilePath, NuGetRestor
builder.Append(settings.MSBuildVersion.Value.GetNuGetMSBuildVersionString());
}

builder.Append("-NonInteractive");
// NonInteractive?
if (settings.NonInteractive)
{
builder.Append("-NonInteractive");
}

return builder;
}
Expand Down
11 changes: 11 additions & 0 deletions src/Cake.Common/Tools/NuGet/Restore/NugetRestoreSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,16 @@ public sealed class NuGetRestoreSettings : ToolSettings
/// </summary>
/// <value>The version of MSBuild to be used with this command.</value>
public NuGetMSBuildVersion? MSBuildVersion { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not NuGet suppresses prompts for user input or confirmations.
/// </summary>
/// <remarks>
/// This setting is passed by NuGet.exe to any extensions such as authorization providers
/// </remarks>
/// <value>
/// <c>false</c> to allow NuGet to show prompts for user input or confirmations; otherwise, <c>true</c>.
/// </value>
public bool NonInteractive { get; set; } = true;
}
}