Skip to content

Commit

Permalink
Merge pull request cake-build#2451 from flcdrg/NuGetRestoreSettingsIn…
Browse files Browse the repository at this point in the history
…teractive

GH2345: Add NonInteractive property to NuGetRestoreSettings
  • Loading branch information
bjorkstromm committed Jan 16, 2019
2 parents 408499f + 0320c22 commit 8332c3a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
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);
}
}
}
}
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
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
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;
}
}

0 comments on commit 8332c3a

Please sign in to comment.