Skip to content

Commit

Permalink
(GH-4412) NuGetInstall Add NoHttpCache, obsolete NoCache
Browse files Browse the repository at this point in the history
* fixes #4412
  • Loading branch information
devlead committed Jan 17, 2025
1 parent 7a7fc19 commit 8b477df
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
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

0 comments on commit 8b477df

Please sign in to comment.