diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
index f5625b0d64..5901d6274b 100644
--- a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
@@ -800,6 +800,54 @@ public static void DotNetNuGetAddSource(this ICakeContext context, string name,
sourcer.AddSource(name, settings);
}
+ ///
+ /// Disable the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ ///
+ ///
+ /// DotNetNuGetDisableSource("example");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetDisableSource(this ICakeContext context, string name)
+ {
+ context.DotNetNuGetDisableSource(name, null);
+ }
+
+ ///
+ /// Disable the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetSourceSettings
+ /// {
+ /// ConfigFile = "NuGet.config"
+ /// };
+ ///
+ /// DotNetNuGetDisableSource("example", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetDisableSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var sourcer = new DotNetCoreNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ sourcer.DisableSource(name, settings ?? new DotNetNuGetSourceSettings());
+ }
+
///
/// Package all projects.
///
diff --git a/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetDisableSourceSettings.cs b/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetDisableSourceSettings.cs
new file mode 100644
index 0000000000..2464af9b0e
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetDisableSourceSettings.cs
@@ -0,0 +1,15 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Cake.Common.Tools.DotNetCore.NuGet.Source;
+
+namespace Cake.Common.Tools.DotNet.NuGet.Source
+{
+ ///
+ /// Contains settings used by for disabling NuGet sources.
+ ///
+ public class DotNetNuGetDisableSourceSettings : DotNetNuGetSourceSettings
+ {
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
index 35cc7389ca..42ff13d110 100644
--- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
+++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
@@ -917,6 +917,7 @@ public static void DotNetCoreNuGetAddSource(this ICakeContext context, string na
}
///
+ /// [deprecated] DotNetCoreNuGetDisableSource is obsolete and will be removed in a future release. Use instead.
/// Disable the specified NuGet source.
///
/// The context.
@@ -929,12 +930,14 @@ public static void DotNetCoreNuGetAddSource(this ICakeContext context, string na
[CakeMethodAlias]
[CakeAliasCategory("NuGet")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.NuGet.Source")]
+ [Obsolete("DotNetCoreNuGetDisableSource is obsolete and will be removed in a future release. Use DotNetNuGetDisableSource instead.")]
public static void DotNetCoreNuGetDisableSource(this ICakeContext context, string name)
{
- context.DotNetCoreNuGetDisableSource(name, null);
+ context.DotNetNuGetDisableSource(name);
}
///
+ /// [deprecated] DotNetCoreNuGetDisableSource is obsolete and will be removed in a future release. Use instead.
/// Disable the specified NuGet source.
///
/// The context.
@@ -953,15 +956,10 @@ public static void DotNetCoreNuGetDisableSource(this ICakeContext context, strin
[CakeMethodAlias]
[CakeAliasCategory("NuGet")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.NuGet.Source")]
+ [Obsolete("DotNetCoreNuGetDisableSource is obsolete and will be removed in a future release. Use DotNetNuGetDisableSource instead.")]
public static void DotNetCoreNuGetDisableSource(this ICakeContext context, string name, DotNetCoreNuGetSourceSettings settings)
{
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var sourcer = new DotNetCoreNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- sourcer.DisableSource(name, settings ?? new DotNetCoreNuGetSourceSettings());
+ context.DotNetNuGetDisableSource(name, settings);
}
///
diff --git a/src/Cake.Common/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcer.cs b/src/Cake.Common/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcer.cs
index e01e36ecda..5a192c51eb 100644
--- a/src/Cake.Common/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcer.cs
+++ b/src/Cake.Common/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcer.cs
@@ -65,7 +65,7 @@ public void AddSource(string name, DotNetNuGetSourceSettings settings)
///
/// The name of the source.
/// The settings.
- public void DisableSource(string name, DotNetCoreNuGetSourceSettings settings)
+ public void DisableSource(string name, DotNetNuGetSourceSettings settings)
{
if (string.IsNullOrWhiteSpace(name))
{
@@ -223,7 +223,7 @@ private ProcessArgumentBuilder GetAddSourceArguments(string name, DotNetNuGetSou
return builder;
}
- private ProcessArgumentBuilder GetDisableSourceArguments(string name, DotNetCoreNuGetSourceSettings settings)
+ private ProcessArgumentBuilder GetDisableSourceArguments(string name, DotNetNuGetSourceSettings settings)
{
var builder = CreateArgumentBuilder(settings);