diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
index f8b3182fb1..facc942cc9 100644
--- a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
@@ -8,11 +8,13 @@
using Cake.Common.Tools.DotNet.Clean;
using Cake.Common.Tools.DotNet.Execute;
using Cake.Common.Tools.DotNet.MSBuild;
+using Cake.Common.Tools.DotNet.Restore;
using Cake.Common.Tools.DotNet.Run;
using Cake.Common.Tools.DotNet.Tool;
using Cake.Common.Tools.DotNetCore.Clean;
using Cake.Common.Tools.DotNetCore.Execute;
using Cake.Common.Tools.DotNetCore.MSBuild;
+using Cake.Common.Tools.DotNetCore.Restore;
using Cake.Common.Tools.DotNetCore.Run;
using Cake.Common.Tools.DotNetCore.Tool;
using Cake.Core;
@@ -110,6 +112,109 @@ public static void DotNetExecute(this ICakeContext context, FilePath assemblyPat
executor.Execute(assemblyPath, arguments, settings);
}
+ ///
+ /// Restore all NuGet Packages.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetRestore();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Restore")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Restore")]
+ public static void DotNetRestore(this ICakeContext context)
+ {
+ context.DotNetRestore(null, null);
+ }
+
+ ///
+ /// Restore all NuGet Packages in the specified path.
+ ///
+ /// The context.
+ /// List of projects and project folders to restore. Each value can be: a path to a project.json or global.json file, or a folder to recursively search for project.json files.
+ ///
+ ///
+ /// DotNetRestore("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Restore")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Restore")]
+ public static void DotNetRestore(this ICakeContext context, string root)
+ {
+ context.DotNetRestore(root, null);
+ }
+
+ ///
+ /// Restore all NuGet Packages with the settings.
+ ///
+ /// The context.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetRestoreSettings
+ /// {
+ /// Sources = new[] {"https://www.example.com/nugetfeed", "https://www.example.com/nugetfeed2"},
+ /// FallbackSources = new[] {"https://www.example.com/fallbacknugetfeed"},
+ /// PackagesDirectory = "./packages",
+ /// Verbosity = Information,
+ /// DisableParallel = true,
+ /// InferRuntimes = new[] {"runtime1", "runtime2"}
+ /// };
+ ///
+ /// DotNetRestore(settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Restore")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Restore")]
+ public static void DotNetRestore(this ICakeContext context, DotNetRestoreSettings settings)
+ {
+ context.DotNetRestore(null, settings);
+ }
+
+ ///
+ /// Restore all NuGet Packages in the specified path with settings.
+ ///
+ /// The context.
+ /// List of projects and project folders to restore. Each value can be: a path to a project.json or global.json file, or a folder to recursively search for project.json files.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetRestoreSettings
+ /// {
+ /// Sources = new[] {"https://www.example.com/nugetfeed", "https://www.example.com/nugetfeed2"},
+ /// FallbackSources = new[] {"https://www.example.com/fallbacknugetfeed"},
+ /// PackagesDirectory = "./packages",
+ /// Verbosity = Information,
+ /// DisableParallel = true,
+ /// InferRuntimes = new[] {"runtime1", "runtime2"}
+ /// };
+ ///
+ /// DotNetRestore("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Restore")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Restore")]
+ public static void DotNetRestore(this ICakeContext context, string root, DotNetRestoreSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetRestoreSettings();
+ }
+
+ var restorer = new DotNetCoreRestorer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);
+ restorer.Restore(root, settings);
+ }
+
///
/// Cleans a project's output.
///
diff --git a/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs b/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs
new file mode 100644
index 0000000000..0f9c3790cd
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs
@@ -0,0 +1,118 @@
+// 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 System.Collections.Generic;
+using Cake.Common.Tools.DotNetCore;
+using Cake.Common.Tools.DotNetCore.MSBuild;
+using Cake.Common.Tools.DotNetCore.Restore;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet.Restore
+{
+ ///
+ /// Contains settings used by .
+ ///
+ public class DotNetRestoreSettings : DotNetCoreSettings
+ {
+ ///
+ /// Gets or sets the specified NuGet package sources to use during the restore.
+ ///
+ public ICollection Sources { get; set; } = new List();
+
+ ///
+ /// Gets or sets the NuGet configuration file to use.
+ ///
+ public FilePath ConfigFile { get; set; }
+
+ ///
+ /// Gets or sets the directory to install packages in.
+ ///
+ public DirectoryPath PackagesDirectory { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to do not cache packages and http requests.
+ ///
+ public bool NoCache { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to disable restoring multiple projects in parallel.
+ ///
+ public bool DisableParallel { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to only warning failed sources if there are packages meeting version requirement.
+ ///
+ public bool IgnoreFailedSources { get; set; }
+
+ ///
+ /// Gets or sets the target runtime to restore packages for.
+ ///
+ public string Runtime { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to ignore project to project references and restore only the root project.
+ ///
+ public bool NoDependencies { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to force all dependencies to be resolved even if the last restore was successful.
+ /// This is equivalent to deleting the project.assets.json file.
+ ///
+ /// Note: This flag was introduced with the .NET Core 2.x release.
+ ///
+ public bool Force { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to stop and wait for user input or action (for example to complete authentication).
+ ///
+ ///
+ /// Supported by .NET SDK version 2.1.400 and above.
+ ///
+ public bool Interactive { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to enable project lock file to be generated and used with restore.
+ ///
+ ///
+ /// Supported by .NET SDK version 2.1.500 and above.
+ ///
+ public bool UseLockFile { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to not allow updating project lock file.
+ ///
+ ///
+ /// When set to true, restore will fail if the lock file is out of sync.
+ /// Useful for CI builds when you do not want the build to continue if the package closure has changed than what is present in the lock file.
+ ///
+ /// Supported by .NET SDK version 2.1.500 and above.
+ ///
+ ///
+ public bool LockedMode { get; set; }
+
+ ///
+ /// Gets or sets a value indicating output location where project lock file is written.
+ ///
+ ///
+ /// If not set, 'dotnet restore' defaults to 'PROJECT_ROOT\packages.lock.json'.
+ ///
+ /// Supported by .NET SDK version 2.1.500 and above.
+ ///
+ ///
+ public FilePath LockFilePath { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to force restore to reevaluate all dependencies even if a lock file already exists.
+ ///
+ ///
+ /// Supported by .NET SDK version 2.1.500 and above.
+ ///
+ public bool ForceEvaluate { get; set; }
+
+ ///
+ /// Gets or sets additional arguments to be passed to MSBuild.
+ ///
+ public DotNetCoreMSBuildSettings MSBuildSettings { get; set; }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
index a30d95dc25..993095861f 100644
--- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
+++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cs
@@ -9,6 +9,7 @@
using Cake.Common.Tools.DotNet.Clean;
using Cake.Common.Tools.DotNet.Execute;
using Cake.Common.Tools.DotNet.MSBuild;
+using Cake.Common.Tools.DotNet.Restore;
using Cake.Common.Tools.DotNet.Run;
using Cake.Common.Tools.DotNet.Tool;
using Cake.Common.Tools.DotNetCore.Build;
@@ -112,6 +113,7 @@ public static void DotNetCoreExecute(this ICakeContext context, FilePath assembl
}
///
+ /// [deprecated] DotNetCoreRestore is obsolete and will be removed in a future release. Use instead.
/// Restore all NuGet Packages.
///
/// The context.
@@ -123,12 +125,14 @@ public static void DotNetCoreExecute(this ICakeContext context, FilePath assembl
[CakeMethodAlias]
[CakeAliasCategory("Restore")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Restore")]
+ [Obsolete("DotNetCoreRestore is obsolete and will be removed in a future release. Use DotNetRestore instead.")]
public static void DotNetCoreRestore(this ICakeContext context)
{
- context.DotNetCoreRestore(null, null);
+ context.DotNetRestore();
}
///
+ /// [deprecated] DotNetCoreRestore is obsolete and will be removed in a future release. Use instead.
/// Restore all NuGet Packages in the specified path.
///
/// The context.
@@ -141,12 +145,14 @@ public static void DotNetCoreRestore(this ICakeContext context)
[CakeMethodAlias]
[CakeAliasCategory("Restore")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Restore")]
+ [Obsolete("DotNetCoreRestore is obsolete and will be removed in a future release. Use DotNetRestore instead.")]
public static void DotNetCoreRestore(this ICakeContext context, string root)
{
- context.DotNetCoreRestore(root, null);
+ context.DotNetRestore(root);
}
///
+ /// [deprecated] DotNetCoreRestore is obsolete and will be removed in a future release. Use instead.
/// Restore all NuGet Packages with the settings.
///
/// The context.
@@ -169,12 +175,14 @@ public static void DotNetCoreRestore(this ICakeContext context, string root)
[CakeMethodAlias]
[CakeAliasCategory("Restore")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Restore")]
+ [Obsolete("DotNetCoreRestore is obsolete and will be removed in a future release. Use DotNetRestore instead.")]
public static void DotNetCoreRestore(this ICakeContext context, DotNetCoreRestoreSettings settings)
{
- context.DotNetCoreRestore(null, settings);
+ context.DotNetRestore(settings);
}
///
+ /// [deprecated] DotNetCoreRestore is obsolete and will be removed in a future release. Use instead.
/// Restore all NuGet Packages in the specified path with settings.
///
/// The context.
@@ -198,20 +206,10 @@ public static void DotNetCoreRestore(this ICakeContext context, DotNetCoreRestor
[CakeMethodAlias]
[CakeAliasCategory("Restore")]
[CakeNamespaceImport("Cake.Common.Tools.DotNetCore.Restore")]
+ [Obsolete("DotNetCoreRestore is obsolete and will be removed in a future release. Use DotNetRestore instead.")]
public static void DotNetCoreRestore(this ICakeContext context, string root, DotNetCoreRestoreSettings settings)
{
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetCoreRestoreSettings();
- }
-
- var restorer = new DotNetCoreRestorer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);
- restorer.Restore(root, settings);
+ context.DotNetRestore(root, settings);
}
///
diff --git a/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestoreSettings.cs b/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestoreSettings.cs
index b04895396e..01b3e68353 100644
--- a/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestoreSettings.cs
+++ b/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestoreSettings.cs
@@ -2,115 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Collections.Generic;
-using Cake.Common.Tools.DotNetCore.MSBuild;
-using Cake.Core.IO;
+using Cake.Common.Tools.DotNet.Restore;
namespace Cake.Common.Tools.DotNetCore.Restore
{
///
/// Contains settings used by .
///
- public sealed class DotNetCoreRestoreSettings : DotNetCoreSettings
+ public sealed class DotNetCoreRestoreSettings : DotNetRestoreSettings
{
- ///
- /// Gets or sets the specified NuGet package sources to use during the restore.
- ///
- public ICollection Sources { get; set; } = new List();
-
- ///
- /// Gets or sets the NuGet configuration file to use.
- ///
- public FilePath ConfigFile { get; set; }
-
- ///
- /// Gets or sets the directory to install packages in.
- ///
- public DirectoryPath PackagesDirectory { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to do not cache packages and http requests.
- ///
- public bool NoCache { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to disable restoring multiple projects in parallel.
- ///
- public bool DisableParallel { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to only warning failed sources if there are packages meeting version requirement.
- ///
- public bool IgnoreFailedSources { get; set; }
-
- ///
- /// Gets or sets the target runtime to restore packages for.
- ///
- public string Runtime { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to ignore project to project references and restore only the root project.
- ///
- public bool NoDependencies { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to force all dependencies to be resolved even if the last restore was successful.
- /// This is equivalent to deleting the project.assets.json file.
- ///
- /// Note: This flag was introduced with the .NET Core 2.x release.
- ///
- public bool Force { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to stop and wait for user input or action (for example to complete authentication).
- ///
- ///
- /// Supported by .NET SDK version 2.1.400 and above.
- ///
- public bool Interactive { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to enable project lock file to be generated and used with restore.
- ///
- ///
- /// Supported by .NET SDK version 2.1.500 and above.
- ///
- public bool UseLockFile { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to not allow updating project lock file.
- ///
- ///
- /// When set to true, restore will fail if the lock file is out of sync.
- /// Useful for CI builds when you do not want the build to continue if the package closure has changed than what is present in the lock file.
- ///
- /// Supported by .NET SDK version 2.1.500 and above.
- ///
- ///
- public bool LockedMode { get; set; }
-
- ///
- /// Gets or sets a value indicating output location where project lock file is written.
- ///
- ///
- /// If not set, 'dotnet restore' defaults to 'PROJECT_ROOT\packages.lock.json'.
- ///
- /// Supported by .NET SDK version 2.1.500 and above.
- ///
- ///
- public FilePath LockFilePath { get; set; }
-
- ///
- /// Gets or sets a value indicating whether to force restore to reevaluate all dependencies even if a lock file already exists.
- ///
- ///
- /// Supported by .NET SDK version 2.1.500 and above.
- ///
- public bool ForceEvaluate { get; set; }
-
- ///
- /// Gets or sets additional arguments to be passed to MSBuild.
- ///
- public DotNetCoreMSBuildSettings MSBuildSettings { get; set; }
}
}
diff --git a/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestorer.cs b/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestorer.cs
index abc49f0684..a262bd0a0b 100644
--- a/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestorer.cs
+++ b/src/Cake.Common/Tools/DotNetCore/Restore/DotNetCoreRestorer.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
+using Cake.Common.Tools.DotNet.Restore;
using Cake.Common.Tools.DotNetCore.MSBuild;
using Cake.Core;
using Cake.Core.Diagnostics;
@@ -14,7 +15,7 @@ namespace Cake.Common.Tools.DotNetCore.Restore
///
/// .NET Core project restorer.
///
- public sealed class DotNetCoreRestorer : DotNetCoreTool
+ public sealed class DotNetCoreRestorer : DotNetCoreTool
{
private readonly ICakeEnvironment _environment;
private readonly ICakeLog _log;
@@ -43,7 +44,7 @@ public DotNetCoreRestorer(
///
/// List of projects and project folders to restore. Each value can be: a path to a project.json or global.json file, or a folder to recursively search for project.json files.
/// The settings.
- public void Restore(string root, DotNetCoreRestoreSettings settings)
+ public void Restore(string root, DotNetRestoreSettings settings)
{
if (settings == null)
{
@@ -53,7 +54,7 @@ public void Restore(string root, DotNetCoreRestoreSettings settings)
RunCommand(settings, GetArguments(root, settings));
}
- private ProcessArgumentBuilder GetArguments(string root, DotNetCoreRestoreSettings settings)
+ private ProcessArgumentBuilder GetArguments(string root, DotNetRestoreSettings settings)
{
var builder = CreateArgumentBuilder(settings);