Skip to content

Commit 8b477df

Browse files
committed
(GH-4412) NuGetInstall Add NoHttpCache, obsolete NoCache
* fixes #4412
1 parent 7a7fc19 commit 8b477df

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

src/Cake.Common.Tests/Unit/Tools/NuGet/Install/NuGetInstallerSettingsTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ public void Should_Set_NoCache_To_False_By_Default()
1818
var settings = new NuGetInstallSettings();
1919

2020
// Then
21+
#pragma warning disable CS0618
2122
Assert.False(settings.NoCache);
23+
#pragma warning restore CS0618
24+
}
25+
26+
[Fact]
27+
public void Should_Set_NoHttpCache_To_False_By_Default()
28+
{
29+
// Given, When
30+
var settings = new NuGetInstallSettings();
31+
32+
// Then
33+
Assert.False(settings.NoHttpCache);
2234
}
2335

2436
[Fact]

src/Cake.Common.Tests/Unit/Tools/NuGet/Install/NuGetInstallerTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ public void Should_Add_NoCache_To_Arguments_If_True()
191191
{
192192
// Given
193193
var fixture = new NuGetInstallerFixture();
194+
#pragma warning disable CS0618
194195
fixture.Settings.NoCache = true;
196+
#pragma warning restore CS0618
195197

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

205+
[Fact]
206+
public void Should_Add_NoHttpCache_To_Arguments_If_True()
207+
{
208+
// Given
209+
var fixture = new NuGetInstallerFixture();
210+
fixture.Settings.NoHttpCache = true;
211+
212+
// When
213+
var result = fixture.Run();
214+
215+
// Then
216+
Assert.Equal("install \"Cake\" -NoHttpCache -NonInteractive", result.Args);
217+
}
218+
203219
[Fact]
204220
public void Should_Add_DisableParallelProcessing_To_Arguments_If_Set()
205221
{
@@ -460,7 +476,9 @@ public void Should_Add_NoCache_To_Arguments_If_True()
460476
{
461477
// Given
462478
var fixture = new NuGetInstallerFromConfigFixture();
479+
#pragma warning disable CS0618
463480
fixture.Settings.NoCache = true;
481+
#pragma warning restore CS0618
464482

465483
// When
466484
var result = fixture.Run();
@@ -470,6 +488,21 @@ public void Should_Add_NoCache_To_Arguments_If_True()
470488
"-NonInteractive", result.Args);
471489
}
472490

491+
[Fact]
492+
public void Should_Add_NoHttpCache_To_Arguments_If_True()
493+
{
494+
// Given
495+
var fixture = new NuGetInstallerFromConfigFixture();
496+
fixture.Settings.NoHttpCache = true;
497+
498+
// When
499+
var result = fixture.Run();
500+
501+
// Then
502+
Assert.Equal("install \"/Working/packages.config\" -NoHttpCache " +
503+
"-NonInteractive", result.Args);
504+
}
505+
473506
[Fact]
474507
public void Should_Add_DisableParallelProcessing_To_Arguments_If_Set()
475508
{

src/Cake.Common/Tools/NuGet/Install/NuGetInstallSettings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,17 @@ public sealed class NuGetInstallSettings : ToolSettings
7171
/// <value>
7272
/// <c>true</c> to not use the machine cache as the first package source; otherwise, <c>false</c>.
7373
/// </value>
74+
[System.Obsolete("NoCache is deprecated and has been renamed to NoHttpCache. Please use NoHttpCache instead.")]
7475
public bool NoCache { get; set; }
7576

77+
/// <summary>
78+
/// Gets or sets a value indicating whether or not use the HTTP cache and contact all configured package sources for live information.
79+
/// </summary>
80+
/// <value>
81+
/// <c>true</c> to not use the HTTP cache and contact package sources for live information; otherwise, <c>false</c>.
82+
/// </value>
83+
public bool NoHttpCache { get; set; }
84+
7685
/// <summary>
7786
/// Gets or sets a value indicating whether to disable parallel processing of packages for this command.
7887
/// Disable parallel processing of packages for this command.

src/Cake.Common/Tools/NuGet/Install/NuGetInstaller.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,18 @@ private ProcessArgumentBuilder GetArguments(string packageId, NuGetInstallSettin
136136
}
137137

138138
// No Cache?
139+
#pragma warning disable CS0618
139140
if (settings.NoCache)
140141
{
141142
builder.Append("-NoCache");
142143
}
144+
#pragma warning restore CS0618
145+
146+
// No Http Cache?
147+
if (settings.NoHttpCache)
148+
{
149+
builder.Append("-NoHttpCache");
150+
}
143151

144152
// Disable Parallel Processing?
145153
if (settings.DisableParallelProcessing)

0 commit comments

Comments
 (0)