Skip to content

Commit

Permalink
(cake-build#3639) Add DotNetNuGetDisableSource aliases (synonym to Do…
Browse files Browse the repository at this point in the history
…tNetCoreNuGetDisableSource)
  • Loading branch information
augustoproiete committed Nov 4, 2021
1 parent dc550dd commit fe303de
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
48 changes: 48 additions & 0 deletions src/Cake.Common/Tools/DotNet/DotNetAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,54 @@ public static void DotNetNuGetAddSource(this ICakeContext context, string name,
sourcer.AddSource(name, settings);
}

/// <summary>
/// Disable the specified NuGet source.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="name">The name of the source.</param>
/// <example>
/// <code>
/// DotNetNuGetDisableSource("example");
/// </code>
/// </example>
[CakeMethodAlias]
[CakeAliasCategory("NuGet")]
[CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
public static void DotNetNuGetDisableSource(this ICakeContext context, string name)
{
context.DotNetNuGetDisableSource(name, null);
}

/// <summary>
/// Disable the specified NuGet source.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="name">The name of the source.</param>
/// <param name="settings">The settings.</param>
/// <example>
/// <code>
/// var settings = new DotNetNuGetSourceSettings
/// {
/// ConfigFile = "NuGet.config"
/// };
///
/// DotNetNuGetDisableSource("example", settings);
/// </code>
/// </example>
[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());
}

/// <summary>
/// Package all projects.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Contains settings used by <see cref="DotNetCoreNuGetSourcer" /> for disabling NuGet sources.
/// </summary>
public class DotNetNuGetDisableSourceSettings : DotNetNuGetSourceSettings
{
}
}
14 changes: 6 additions & 8 deletions src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ public static void DotNetCoreNuGetAddSource(this ICakeContext context, string na
}

/// <summary>
/// [deprecated] DotNetCoreNuGetDisableSource is obsolete and will be removed in a future release. Use <see cref="DotNetAliases.DotNetNuGetDisableSource(ICakeContext, string)" /> instead.
/// Disable the specified NuGet source.
/// </summary>
/// <param name="context">The context.</param>
Expand All @@ -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);
}

/// <summary>
/// [deprecated] DotNetCoreNuGetDisableSource is obsolete and will be removed in a future release. Use <see cref="DotNetAliases.DotNetNuGetDisableSource(ICakeContext, string, DotNetNuGetSourceSettings)" /> instead.
/// Disable the specified NuGet source.
/// </summary>
/// <param name="context">The context.</param>
Expand All @@ -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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void AddSource(string name, DotNetNuGetSourceSettings settings)
/// </summary>
/// <param name="name">The name of the source.</param>
/// <param name="settings">The settings.</param>
public void DisableSource(string name, DotNetCoreNuGetSourceSettings settings)
public void DisableSource(string name, DotNetNuGetSourceSettings settings)
{
if (string.IsNullOrWhiteSpace(name))
{
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit fe303de

Please sign in to comment.