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

GH4412: NuGetInstall Add NoHttpCache, obsolete NoCache #4451

Merged
merged 1 commit into from
Jan 17, 2025
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 @@ -18,7 +18,19 @@ public void Should_Set_NoCache_To_False_By_Default()
var settings = new NuGetInstallSettings();

// Then
#pragma warning disable CS0618
Assert.False(settings.NoCache);
#pragma warning restore CS0618
}

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

// Then
Assert.False(settings.NoHttpCache);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ public void Should_Add_NoCache_To_Arguments_If_True()
{
// Given
var fixture = new NuGetInstallerFixture();
#pragma warning disable CS0618
fixture.Settings.NoCache = true;
#pragma warning restore CS0618

// When
var result = fixture.Run();
Expand All @@ -200,6 +202,20 @@ public void Should_Add_NoCache_To_Arguments_If_True()
Assert.Equal("install \"Cake\" -NoCache -NonInteractive", result.Args);
}

[Fact]
public void Should_Add_NoHttpCache_To_Arguments_If_True()
{
// Given
var fixture = new NuGetInstallerFixture();
fixture.Settings.NoHttpCache = true;

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

// Then
Assert.Equal("install \"Cake\" -NoHttpCache -NonInteractive", result.Args);
}

[Fact]
public void Should_Add_DisableParallelProcessing_To_Arguments_If_Set()
{
Expand Down Expand Up @@ -460,7 +476,9 @@ public void Should_Add_NoCache_To_Arguments_If_True()
{
// Given
var fixture = new NuGetInstallerFromConfigFixture();
#pragma warning disable CS0618
fixture.Settings.NoCache = true;
#pragma warning restore CS0618

// When
var result = fixture.Run();
Expand All @@ -470,6 +488,21 @@ public void Should_Add_NoCache_To_Arguments_If_True()
"-NonInteractive", result.Args);
}

[Fact]
public void Should_Add_NoHttpCache_To_Arguments_If_True()
{
// Given
var fixture = new NuGetInstallerFromConfigFixture();
fixture.Settings.NoHttpCache = true;

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

// Then
Assert.Equal("install \"/Working/packages.config\" -NoHttpCache " +
"-NonInteractive", result.Args);
}

[Fact]
public void Should_Add_DisableParallelProcessing_To_Arguments_If_Set()
{
Expand Down
9 changes: 9 additions & 0 deletions src/Cake.Common/Tools/NuGet/Install/NuGetInstallSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,17 @@ public sealed class NuGetInstallSettings : ToolSettings
/// <value>
/// <c>true</c> to not use the machine cache as the first package source; otherwise, <c>false</c>.
/// </value>
[System.Obsolete("NoCache is deprecated and has been renamed to NoHttpCache. Please use NoHttpCache instead.")]
public bool NoCache { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not use the HTTP cache and contact all configured package sources for live information.
/// </summary>
/// <value>
/// <c>true</c> to not use the HTTP cache and contact package sources for live information; otherwise, <c>false</c>.
/// </value>
public bool NoHttpCache { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to disable parallel processing of packages for this command.
/// Disable parallel processing of packages for this command.
Expand Down
8 changes: 8 additions & 0 deletions src/Cake.Common/Tools/NuGet/Install/NuGetInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,18 @@ private ProcessArgumentBuilder GetArguments(string packageId, NuGetInstallSettin
}

// No Cache?
#pragma warning disable CS0618
if (settings.NoCache)
{
builder.Append("-NoCache");
}
#pragma warning restore CS0618

// No Http Cache?
if (settings.NoHttpCache)
{
builder.Append("-NoHttpCache");
}

// Disable Parallel Processing?
if (settings.DisableParallelProcessing)
Expand Down
Loading