diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Build.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Build.cs
new file mode 100644
index 0000000000..59bbda0847
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Build.cs
@@ -0,0 +1,77 @@
+// 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;
+using Cake.Common.Tools.DotNet.Build;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Build all projects.
+ ///
+ /// The context.
+ /// The projects path.
+ ///
+ ///
+ /// DotNetBuild("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Build")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Build")]
+ public static void DotNetBuild(this ICakeContext context, string project)
+ {
+ context.DotNetBuild(project, null);
+ }
+
+ ///
+ /// Build all projects.
+ ///
+ /// The context.
+ /// The projects path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetBuildSettings
+ /// {
+ /// Framework = "netcoreapp2.0",
+ /// Configuration = "Debug",
+ /// OutputDirectory = "./artifacts/"
+ /// };
+ ///
+ /// DotNetBuild("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Build")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Build")]
+ public static void DotNetBuild(this ICakeContext context, string project, DotNetBuildSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetBuildSettings();
+ }
+
+ var builder = new DotNetBuilder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ builder.Build(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.BuildServer.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.BuildServer.cs
new file mode 100644
index 0000000000..6e95f9ea20
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.BuildServer.cs
@@ -0,0 +1,69 @@
+// 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;
+using Cake.Common.Tools.DotNet.BuildServer;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Shuts down build servers that are started from dotnet.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetBuildServerShutdown();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Build Server")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.BuildServer")]
+ public static void DotNetBuildServerShutdown(this ICakeContext context)
+ {
+ context.DotNetBuildServerShutdown(null);
+ }
+
+ ///
+ /// Shuts down build servers that are started from dotnet.
+ ///
+ /// The context.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetBuildServerShutdownSettings
+ /// {
+ /// MSBuild = true
+ /// };
+ ///
+ /// DotNetBuildServerShutdown(settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Build Server")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.BuildServer")]
+ public static void DotNetBuildServerShutdown(this ICakeContext context, DotNetBuildServerShutdownSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var buildServer = new DotNetBuildServer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+
+ buildServer.Shutdown(settings ?? new DotNetBuildServerShutdownSettings());
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Clean.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Clean.cs
new file mode 100644
index 0000000000..de3f998216
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Clean.cs
@@ -0,0 +1,77 @@
+// 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;
+using Cake.Common.Tools.DotNet.Clean;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Cleans a project's output.
+ ///
+ /// The context.
+ /// The project's path.
+ ///
+ ///
+ /// DotNetClean("./src/project");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Clean")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Clean")]
+ public static void DotNetClean(this ICakeContext context, string project)
+ {
+ context.DotNetClean(project, null);
+ }
+
+ ///
+ /// Cleans a project's output.
+ ///
+ /// The context.
+ /// The projects path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetCleanSettings
+ /// {
+ /// Framework = "netcoreapp2.0",
+ /// Configuration = "Debug",
+ /// OutputDirectory = "./artifacts/"
+ /// };
+ ///
+ /// DotNetClean("./src/project", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Clean")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Clean")]
+ public static void DotNetClean(this ICakeContext context, string project, DotNetCleanSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetCleanSettings();
+ }
+
+ var cleaner = new DotNetCleaner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ cleaner.Clean(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Execute.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Execute.cs
new file mode 100644
index 0000000000..f6a03ca36a
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Execute.cs
@@ -0,0 +1,101 @@
+// 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;
+using Cake.Common.Tools.DotNet.Execute;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Execute an assembly.
+ ///
+ /// The context.
+ /// The assembly path.
+ ///
+ ///
+ /// DotNetExecute("./bin/Debug/app.dll");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Execute")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")]
+ public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath)
+ {
+ context.DotNetExecute(assemblyPath, null);
+ }
+
+ ///
+ /// Execute an assembly with arguments in the specific path.
+ ///
+ /// The context.
+ /// The assembly path.
+ /// The arguments.
+ ///
+ ///
+ /// DotNetExecute("./bin/Debug/app.dll", "--arg");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Execute")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")]
+ public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments)
+ {
+ context.DotNetExecute(assemblyPath, arguments, null);
+ }
+
+ ///
+ /// Execute an assembly with arguments in the specific path with settings.
+ ///
+ /// The context.
+ /// The assembly path.
+ /// The arguments.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetExecuteSettings
+ /// {
+ /// FrameworkVersion = "1.0.3"
+ /// };
+ ///
+ /// DotNetExecute("./bin/Debug/app.dll", "--arg", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Execute")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")]
+ public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments, DotNetExecuteSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (assemblyPath is null)
+ {
+ throw new ArgumentNullException(nameof(assemblyPath));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetExecuteSettings();
+ }
+
+ var executor = new DotNetExecutor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ executor.Execute(assemblyPath, arguments, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Format.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Format.cs
new file mode 100644
index 0000000000..aa880e9f4f
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Format.cs
@@ -0,0 +1,239 @@
+// 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;
+using Cake.Common.Tools.DotNet.Format;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Formats code to match editorconfig settings.
+ ///
+ /// The context.
+ /// The project or solution path.
+ ///
+ ///
+ /// DotNetFormat("./src/project");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormat(this ICakeContext context, string root)
+ {
+ context.DotNetFormat(root, null);
+ }
+
+ ///
+ /// Formats code to match editorconfig settings.
+ ///
+ /// The context.
+ /// The project or solution path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetFormatSettings
+ /// {
+ /// NoRestore = true,
+ /// Include = "Program.cs Utility\Logging.cs",
+ /// Severity = DotNetFormatSeverity.Error
+ /// };
+ ///
+ /// DotNetFormat("./src/project", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormat(this ICakeContext context, string root, DotNetFormatSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetFormatSettings();
+ }
+
+ var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ formatter.Format(root, null, settings);
+ }
+
+ ///
+ /// Format code to match editorconfig settings for whitespace.
+ ///
+ /// The context.
+ /// The project or solution path.
+ ///
+ ///
+ /// DotNetFormatWhitespace("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormatWhitespace(this ICakeContext context, string root)
+ {
+ context.DotNetFormatWhitespace(root, null);
+ }
+
+ ///
+ /// Format code to match editorconfig settings for whitespace.
+ ///
+ /// The context.
+ /// The project or solution path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetFormatSettings
+ /// {
+ /// NoRestore = true,
+ /// Include = "Program.cs Utility\Logging.cs"
+ /// };
+ ///
+ /// DotNetFormatWhitespace("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormatWhitespace(this ICakeContext context, string root, DotNetFormatSettings settings)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetFormatSettings();
+ }
+
+ var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ formatter.Format(root, "whitespace", settings);
+ }
+
+ ///
+ /// Format code to match editorconfig settings for code style.
+ ///
+ /// The context.
+ /// The project or solution path.
+ ///
+ ///
+ /// DotNetFormatStyle("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormatStyle(this ICakeContext context, string root)
+ {
+ context.DotNetFormatStyle(root, null);
+ }
+
+ ///
+ /// Format code to match editorconfig settings for code style.
+ ///
+ /// The context.
+ /// The project or solution path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetFormatSettings
+ /// {
+ /// NoRestore = true,
+ /// Include = "Program.cs Utility\Logging.cs"
+ /// };
+ ///
+ /// DotNetFormatStyle("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormatStyle(this ICakeContext context, string root, DotNetFormatSettings settings)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetFormatSettings();
+ }
+
+ var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ formatter.Format(root, "style", settings);
+ }
+
+ ///
+ /// Format code to match editorconfig settings for analyzers.
+ ///
+ /// The context.
+ /// The project or solution path.
+ ///
+ ///
+ /// DotNetFormatAnalyzers("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormatAnalyzers(this ICakeContext context, string project)
+ {
+ context.DotNetFormatAnalyzers(project, null);
+ }
+
+ ///
+ /// Format code to match editorconfig settings for analyzers.
+ ///
+ /// The context.
+ /// The project or solution path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetFormatSettings
+ /// {
+ /// NoRestore = true,
+ /// Include = "Program.cs Utility\Logging.cs"
+ /// };
+ ///
+ /// DotNetFormatAnalyzers("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Format")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
+ public static void DotNetFormatAnalyzers(this ICakeContext context, string root, DotNetFormatSettings settings)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetFormatSettings();
+ }
+
+ var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ formatter.Format(root, "analyzers", settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.MSBuild.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.MSBuild.cs
new file mode 100644
index 0000000000..0d79990aed
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.MSBuild.cs
@@ -0,0 +1,129 @@
+// 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;
+using Cake.Common.Tools.DotNet.MSBuild;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Builds the specified targets in a project file found in the current working directory.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetMSBuild();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("MSBuild")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
+ public static void DotNetMSBuild(this ICakeContext context)
+ {
+ context.DotNetMSBuild(null, null);
+ }
+
+ ///
+ /// Builds the specified targets in the project file.
+ ///
+ /// The context.
+ /// Project file or directory to search for project file.
+ ///
+ ///
+ /// DotNetMSBuild("foobar.proj");
+ ///
+ ///
+ ///
+ /// If a directory is specified, MSBuild searches that directory for a project file.
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("MSBuild")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
+ public static void DotNetMSBuild(this ICakeContext context, string projectOrDirectory)
+ {
+ if (string.IsNullOrWhiteSpace(projectOrDirectory))
+ {
+ throw new ArgumentNullException(nameof(projectOrDirectory));
+ }
+
+ context.DotNetMSBuild(projectOrDirectory, null);
+ }
+
+ ///
+ /// Builds the specified targets in a project file found in the current working directory.
+ ///
+ /// The context.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetMSBuildSettings
+ /// {
+ /// NoLogo = true,
+ /// MaxCpuCount = -1
+ /// };
+ ///
+ /// DotNetMSBuild(settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("MSBuild")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
+ public static void DotNetMSBuild(this ICakeContext context, DotNetMSBuildSettings settings)
+ {
+ context.DotNetMSBuild(null, settings);
+ }
+
+ ///
+ /// Builds the specified targets in the project file.
+ ///
+ /// The context.
+ /// Project file or directory to search for project file.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetMSBuildSettings
+ /// {
+ /// NoLogo = true,
+ /// MaxCpuCount = -1
+ /// };
+ ///
+ /// DotNetMSBuild("foobar.proj", settings);
+ ///
+ ///
+ ///
+ /// If a project file is not specified, MSBuild searches the current working directory for a file that has a file
+ /// extension that ends in "proj" and uses that file. If a directory is specified, MSBuild searches that directory for a project file.
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("MSBuild")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
+ public static void DotNetMSBuild(this ICakeContext context, string projectOrDirectory, DotNetMSBuildSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetMSBuildSettings();
+ }
+
+ var builder = new DotNetMSBuildBuilder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ builder.Build(projectOrDirectory, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.NuGet.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.NuGet.cs
new file mode 100644
index 0000000000..8a934bde0d
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.NuGet.cs
@@ -0,0 +1,488 @@
+// 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;
+using Cake.Common.Tools.DotNet.NuGet.Delete;
+using Cake.Common.Tools.DotNet.NuGet.Push;
+using Cake.Common.Tools.DotNet.NuGet.Source;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Delete a NuGet Package from a server.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetNuGetDelete();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
+ public static void DotNetNuGetDelete(this ICakeContext context)
+ {
+ context.DotNetNuGetDelete(null, null, null);
+ }
+
+ ///
+ /// Deletes a package from nuget.org.
+ ///
+ /// The context.
+ /// Name of package to delete.
+ ///
+ ///
+ /// DotNetNuGetDelete("Microsoft.AspNetCore.Mvc");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
+ public static void DotNetNuGetDelete(this ICakeContext context, string packageName)
+ {
+ context.DotNetNuGetDelete(packageName, null, null);
+ }
+
+ ///
+ /// Deletes a specific version of a package from nuget.org.
+ ///
+ /// The context.
+ /// Name of package to delete.
+ /// Version of package to delete.
+ ///
+ ///
+ /// DotNetRestore("Microsoft.AspNetCore.Mvc", "1.0");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
+ public static void DotNetNuGetDelete(this ICakeContext context, string packageName, string packageVersion)
+ {
+ context.DotNetNuGetDelete(packageName, packageVersion, null);
+ }
+
+ ///
+ /// Deletes a package from a server.
+ ///
+ /// The context.
+ /// Name of package to delete.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetDeleteSettings
+ /// {
+ /// Source = "https://www.example.com/nugetfeed",
+ /// NonInteractive = true
+ /// };
+ ///
+ /// DotNetNuGetDelete("Microsoft.AspNetCore.Mvc", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
+ public static void DotNetNuGetDelete(this ICakeContext context, string packageName, DotNetNuGetDeleteSettings settings)
+ {
+ context.DotNetNuGetDelete(packageName, null, settings);
+ }
+
+ ///
+ /// Deletes a package from a server using the specified settings.
+ ///
+ /// The context.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetDeleteSettings
+ /// {
+ /// Source = "https://www.example.com/nugetfeed",
+ /// NonInteractive = true
+ /// };
+ ///
+ /// DotNetNuGetDelete(settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
+ public static void DotNetNuGetDelete(this ICakeContext context, DotNetNuGetDeleteSettings settings)
+ {
+ context.DotNetNuGetDelete(null, null, settings);
+ }
+
+ ///
+ /// Deletes a package from a server using the specified settings.
+ ///
+ /// The context.
+ /// Name of package to delete.
+ /// Version of package to delete.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetDeleteSettings
+ /// {
+ /// Source = "https://www.example.com/nugetfeed",
+ /// NonInteractive = true
+ /// };
+ ///
+ /// DotNetNuGetDelete("Microsoft.AspNetCore.Mvc", "1.0", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
+ public static void DotNetNuGetDelete(this ICakeContext context, string packageName, string packageVersion, DotNetNuGetDeleteSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetNuGetDeleteSettings();
+ }
+
+ var nugetDeleter = new DotNetNuGetDeleter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ nugetDeleter.Delete(packageName, packageVersion, settings);
+ }
+
+ ///
+ /// Pushes one or more packages to a server.
+ ///
+ /// The context.
+ /// of the package to push.
+ ///
+ ///
+ /// // With FilePath instance
+ /// var packageFilePath = GetFiles("*.nupkg").Single();
+ /// DotNetNuGetPush(packageFilePath);
+ /// // With string parameter
+ /// DotNetNuGetPush("foo*.nupkg");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Push")]
+ public static void DotNetNuGetPush(this ICakeContext context, FilePath packageFilePath)
+ {
+ context.DotNetNuGetPush(packageFilePath, null);
+ }
+
+ ///
+ /// Pushes one or more packages to a server using the specified settings.
+ ///
+ /// The context.
+ /// of the package to push.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetPushSettings
+ /// {
+ /// Source = "https://www.example.com/nugetfeed",
+ /// ApiKey = "4003d786-cc37-4004-bfdf-c4f3e8ef9b3a"
+ /// };
+ /// // With FilePath instance
+ /// var packageFilePath = GetFiles("foo*.nupkg").Single();
+ /// DotNetNuGetPush(packageFilePath);
+ /// // With string parameter
+ /// DotNetNuGetPush("foo*.nupkg", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Push")]
+ public static void DotNetNuGetPush(this ICakeContext context, FilePath packageFilePath, DotNetNuGetPushSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetNuGetPushSettings();
+ }
+
+ var restorer = new DotNetNuGetPusher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ restorer.Push(packageFilePath?.FullPath, settings);
+ }
+
+ ///
+ /// Add the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetSourceSettings
+ /// {
+ /// Source = "https://www.example.com/nugetfeed",
+ /// UserName = "username",
+ /// Password = "password",
+ /// StorePasswordInClearText = true,
+ /// ValidAuthenticationTypes = "basic,negotiate"
+ /// };
+ ///
+ /// DotNetNuGetAddSource("example", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetAddSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ 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 DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ sourcer.DisableSource(name, settings ?? new DotNetNuGetSourceSettings());
+ }
+
+ ///
+ /// Enable the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ ///
+ ///
+ /// DotNetNuGetEnableSource("example");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetEnableSource(this ICakeContext context, string name)
+ {
+ context.DotNetNuGetEnableSource(name, null);
+ }
+
+ ///
+ /// Enable the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetSourceSettings
+ /// {
+ /// ConfigFile = "NuGet.config"
+ /// };
+ ///
+ /// DotNetNuGetEnableSource("example", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetEnableSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ sourcer.EnableSource(name, settings ?? new DotNetNuGetSourceSettings());
+ }
+
+ ///
+ /// Determines whether the specified NuGet source exists.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// Whether the specified NuGet source exists.
+ ///
+ ///
+ /// var exists = DotNetNuGetHasSource("example");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static bool DotNetNuGetHasSource(this ICakeContext context, string name)
+ {
+ return context.DotNetNuGetHasSource(name, null);
+ }
+
+ ///
+ /// Determines whether the specified NuGet source exists.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// The settings.
+ /// Whether the specified NuGet source exists.
+ ///
+ ///
+ /// var settings = new DotNetNuGetSourceSettings
+ /// {
+ /// ConfigFile = "NuGet.config"
+ /// };
+ ///
+ /// var exists = DotNetNuGetHasSource("example", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static bool DotNetNuGetHasSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return sourcer.HasSource(name, settings ?? new DotNetNuGetSourceSettings());
+ }
+
+ ///
+ /// Remove the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ ///
+ ///
+ /// DotNetNuGetRemoveSource("example");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetRemoveSource(this ICakeContext context, string name)
+ {
+ context.DotNetNuGetRemoveSource(name, null);
+ }
+
+ ///
+ /// Remove the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetSourceSettings
+ /// {
+ /// ConfigFile = "NuGet.config"
+ /// };
+ ///
+ /// DotNetNuGetRemoveSource("example", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetRemoveSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ sourcer.RemoveSource(name, settings ?? new DotNetNuGetSourceSettings());
+ }
+
+ ///
+ /// Update the specified NuGet source.
+ ///
+ /// The context.
+ /// The name of the source.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetNuGetSourceSettings
+ /// {
+ /// Source = "https://www.example.com/nugetfeed",
+ /// UserName = "username",
+ /// Password = "password",
+ /// StorePasswordInClearText = true,
+ /// ValidAuthenticationTypes = "basic,negotiate"
+ /// };
+ ///
+ /// DotNetNuGetUpdateSource("example", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("NuGet")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
+ public static void DotNetNuGetUpdateSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ sourcer.UpdateSource(name, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Pack.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Pack.cs
new file mode 100644
index 0000000000..52b9366dc8
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Pack.cs
@@ -0,0 +1,76 @@
+// 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;
+using Cake.Common.Tools.DotNet.Pack;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Package all projects.
+ ///
+ /// The context.
+ /// The projects path.
+ ///
+ ///
+ /// DotNetPack("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Pack")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Pack")]
+ public static void DotNetPack(this ICakeContext context, string project)
+ {
+ context.DotNetPack(project, null);
+ }
+
+ ///
+ /// Package all projects.
+ ///
+ /// The context.
+ /// The projects path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetPackSettings
+ /// {
+ /// Configuration = "Release",
+ /// OutputDirectory = "./artifacts/"
+ /// };
+ ///
+ /// DotNetPack("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Pack")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Pack")]
+ public static void DotNetPack(this ICakeContext context, string project, DotNetPackSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetPackSettings();
+ }
+
+ var packer = new DotNetPacker(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ packer.Pack(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Package.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Package.cs
new file mode 100644
index 0000000000..3670b3df37
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Package.cs
@@ -0,0 +1,335 @@
+// 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;
+using System.Collections.Generic;
+using Cake.Common.Tools.DotNet.Package.Add;
+using Cake.Common.Tools.DotNet.Package.List;
+using Cake.Common.Tools.DotNet.Package.Remove;
+using Cake.Common.Tools.DotNet.Package.Search;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Adds or updates a package reference in a project file.
+ ///
+ /// The context.
+ /// The package reference to add.
+ ///
+ ///
+ /// DotNetAddPackage("Cake.FileHelper");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
+ public static void DotNetAddPackage(this ICakeContext context, string packageName)
+ {
+ context.DotNetAddPackage(packageName, null, null);
+ }
+
+ ///
+ /// Adds or updates a package reference in a project file.
+ ///
+ /// The context.
+ /// The package reference to add.
+ /// The target project file path.
+ ///
+ ///
+ /// DotNetAddPackage("Cake.FileHelper", "ToDo.csproj");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
+ public static void DotNetAddPackage(this ICakeContext context, string packageName, string project)
+ {
+ context.DotNetAddPackage(packageName, project, null);
+ }
+
+ ///
+ /// Adds or updates a package reference in a project file.
+ ///
+ /// The context.
+ /// The package reference to add.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetPackageAddSettings
+ /// {
+ /// NoRestore = true,
+ /// Version = "6.1.3"
+ /// };
+ ///
+ /// DotNetAddPackage("Cake.FileHelper", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
+ public static void DotNetAddPackage(this ICakeContext context, string packageName, DotNetPackageAddSettings settings)
+ {
+ context.DotNetAddPackage(packageName, null, settings);
+ }
+
+ ///
+ /// Adds or updates a package reference in a project file.
+ ///
+ /// The context.
+ /// The package reference to add.
+ /// The target project file path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetPackageAddSettings
+ /// {
+ /// NoRestore = true,
+ /// Version = "6.1.3"
+ /// };
+ ///
+ /// DotNetAddPackage("Cake.FileHelper", "ToDo.csproj", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
+ public static void DotNetAddPackage(this ICakeContext context, string packageName, string project, DotNetPackageAddSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetPackageAddSettings();
+ }
+
+ var adder = new DotNetPackageAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ adder.Add(packageName, project, settings);
+ }
+
+ ///
+ /// Removes package reference from a project file.
+ ///
+ /// The context.
+ /// The package reference to remove.
+ ///
+ ///
+ /// DotNetRemovePackage("Cake.FileHelper");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Remove")]
+ public static void DotNetRemovePackage(this ICakeContext context, string packageName)
+ {
+ context.DotNetRemovePackage(packageName, null);
+ }
+
+ ///
+ /// Removes package reference from a project file.
+ ///
+ /// The context.
+ /// The package reference to remove.
+ /// The target project file path.
+ ///
+ ///
+ /// DotNetRemovePackage("Cake.FileHelper", "ToDo.csproj");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Remove")]
+ public static void DotNetRemovePackage(this ICakeContext context, string packageName, string project)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var adder = new DotNetPackageRemover(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ adder.Remove(packageName, project);
+ }
+
+ ///
+ /// List packages on available from source using specified settings.
+ ///
+ /// The context.
+ /// The search term.
+ /// The settings.
+ /// List of packages with their version.
+ ///
+ ///
+ /// var packageList = DotNetPackageSearch("Cake", new DotNetPackageSearchSettings {
+ /// AllVersions = false,
+ /// Prerelease = false
+ /// });
+ /// foreach(var package in packageList)
+ /// {
+ /// Information("Found package {0}, version {1}", package.Name, package.Version);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Search")]
+ public static IEnumerable DotNetSearchPackage(this ICakeContext context, string searchTerm, DotNetPackageSearchSettings settings)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+ var runner = new DotNetPackageSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return runner.Search(searchTerm, settings);
+ }
+
+ ///
+ /// List packages on available from source using specified settings.
+ ///
+ /// The context.
+ /// The package Id.
+ /// List of packages with their version.
+ ///
+ ///
+ /// var packageList = DotNetPackageSearch("Cake", new DotNetPackageSearchSettings {
+ /// AllVersions = false,
+ /// Prerelease = false
+ /// });
+ /// foreach(var package in packageList)
+ /// {
+ /// Information("Found package {0}, version {1}", package.Name, package.Version);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Search")]
+ public static IEnumerable DotNetSearchPackage(this ICakeContext context, string searchTerm)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+ var runner = new DotNetPackageSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return runner.Search(searchTerm, new DotNetPackageSearchSettings());
+ }
+
+ ///
+ /// List packages on available from source using specified settings.
+ ///
+ /// The context.
+ /// The settings.
+ /// List of packages with their version.
+ ///
+ ///
+ /// var packageList = DotNetPackageSearch("Cake", new DotNetPackageSearchSettings {
+ /// AllVersions = false,
+ /// Prerelease = false
+ /// });
+ /// foreach(var package in packageList)
+ /// {
+ /// Information("Found package {0}, version {1}", package.Name, package.Version);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Search")]
+ public static IEnumerable DotNetSearchPackage(this ICakeContext context, DotNetPackageSearchSettings settings)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+ var runner = new DotNetPackageSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return runner.Search(null, settings);
+ }
+
+ ///
+ /// Lists the package references for a project or solution.
+ ///
+ /// The context.
+ /// The the package references.
+ ///
+ ///
+ /// DotNetPackageList output = DotNetListPackage();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.List")]
+ public static DotNetPackageList DotNetListPackage(this ICakeContext context)
+ {
+ return context.DotNetListPackage(null);
+ }
+
+ ///
+ /// Lists the package references for a project or solution.
+ ///
+ /// The context.
+ /// The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown.
+ /// The the package references.
+ ///
+ ///
+ /// DotNetPackageList output = DotNetListPackage("./src/MyProject/MyProject.csproj");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.List")]
+ public static DotNetPackageList DotNetListPackage(this ICakeContext context, string project)
+ {
+ return context.DotNetListPackage(project, null);
+ }
+
+ ///
+ /// Lists the package references for a project or solution.
+ ///
+ /// The context.
+ /// The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown.
+ /// The settings.
+ /// The the package references.
+ ///
+ ///
+ /// var settings = new DotNetPackageListSettings
+ /// {
+ /// Outdated = true
+ /// };
+ ///
+ /// DotNetPackageList output = DotNetListPackage("./src/MyProject/MyProject.csproj", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Package")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.List")]
+ public static DotNetPackageList DotNetListPackage(this ICakeContext context, string project, DotNetPackageListSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetPackageListSettings();
+ }
+
+ var lister = new DotNetPackageLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return lister.List(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Publish.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Publish.cs
new file mode 100644
index 0000000000..55c8f1d04f
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Publish.cs
@@ -0,0 +1,77 @@
+// 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;
+using Cake.Common.Tools.DotNet.Publish;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Publish all projects.
+ ///
+ /// The context.
+ /// The projects path.
+ ///
+ ///
+ /// DotNetPublish("./src/*");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Publish")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Publish")]
+ public static void DotNetPublish(this ICakeContext context, string project)
+ {
+ context.DotNetPublish(project, null);
+ }
+
+ ///
+ /// Publish all projects.
+ ///
+ /// The context.
+ /// The projects path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetPublishSettings
+ /// {
+ /// Framework = "netcoreapp2.0",
+ /// Configuration = "Release",
+ /// OutputDirectory = "./artifacts/"
+ /// };
+ ///
+ /// DotNetPublish("./src/*", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Publish")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Publish")]
+ public static void DotNetPublish(this ICakeContext context, string project, DotNetPublishSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetPublishSettings();
+ }
+
+ var publisher = new DotNetPublisher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ publisher.Publish(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Reference.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Reference.cs
new file mode 100644
index 0000000000..daf9a52043
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Reference.cs
@@ -0,0 +1,308 @@
+// 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;
+using System.Collections.Generic;
+using Cake.Common.Tools.DotNet.Reference.Add;
+using Cake.Common.Tools.DotNet.Reference.List;
+using Cake.Common.Tools.DotNet.Reference.Remove;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Adds project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
+ ///
+ ///
+ /// DotNetAddReference(GetFiles("./src/*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
+ public static void DotNetAddReference(this ICakeContext context, IEnumerable projectReferences)
+ {
+ context.DotNetAddReference(projectReferences, null);
+ }
+
+ ///
+ /// Adds project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetReferenceAddSettings
+ /// {
+ /// Framework = "net8.0"
+ /// };
+ ///
+ /// DotNetAddReference(GetFiles("./src/*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
+ public static void DotNetAddReference(this ICakeContext context, IEnumerable projectReferences, DotNetReferenceAddSettings settings)
+ {
+ context.DotNetAddReference(null, projectReferences, settings);
+ }
+
+ ///
+ /// Adds project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// The target project file path. If not specified, the command searches the current directory for one.
+ /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
+ ///
+ ///
+ /// DotNetAddReference("./app/app.csproj", GetFiles("./src/*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
+ public static void DotNetAddReference(this ICakeContext context, string project, IEnumerable projectReferences)
+ {
+ context.DotNetAddReference(project, projectReferences, null);
+ }
+
+ ///
+ /// Adds project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// The target project file path. If not specified, the command searches the current directory for one.
+ /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetReferenceAddSettings
+ /// {
+ /// Framework = "net8.0"
+ /// };
+ ///
+ /// DotNetAddReference("./app/app.csproj", GetFiles("./src/*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
+ public static void DotNetAddReference(this ICakeContext context, string project, IEnumerable projectReferences, DotNetReferenceAddSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetReferenceAddSettings();
+ }
+
+ var adder = new DotNetReferenceAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ adder.Add(project, projectReferences, settings);
+ }
+
+ ///
+ /// Removes project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
+ ///
+ ///
+ /// DotNetRemoveReference(GetFiles("./src/*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
+ public static void DotNetRemoveReference(this ICakeContext context, IEnumerable projectReferences)
+ {
+ context.DotNetRemoveReference(projectReferences, null);
+ }
+
+ ///
+ /// Removes project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetReferenceRemoveSettings
+ /// {
+ /// Framework = "net8.0"
+ /// };
+ ///
+ /// DotNetRemoveReference(GetFiles("./src/*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
+ public static void DotNetRemoveReference(this ICakeContext context, IEnumerable projectReferences, DotNetReferenceRemoveSettings settings)
+ {
+ context.DotNetRemoveReference(null, projectReferences, settings);
+ }
+
+ ///
+ /// Removes project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// Target project file. If not specified, the command searches the current directory for one.
+ /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
+ ///
+ ///
+ /// DotNetRemoveReference("./app/app.csproj", GetFiles("./src/*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
+ public static void DotNetRemoveReference(this ICakeContext context, string project, IEnumerable projectReferences)
+ {
+ context.DotNetRemoveReference(project, projectReferences, null);
+ }
+
+ ///
+ /// Removes project-to-project (P2P) references.
+ ///
+ /// The context.
+ /// Target project file. If not specified, the command searches the current directory for one.
+ /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetReferenceRemoveSettings
+ /// {
+ /// Framework = "net8.0"
+ /// };
+ ///
+ /// DotNetRemoveReference("./app/app.csproj", GetFiles("./src/*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
+ public static void DotNetRemoveReference(this ICakeContext context, string project, IEnumerable projectReferences, DotNetReferenceRemoveSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetReferenceRemoveSettings();
+ }
+
+ var remover = new DotNetReferenceRemover(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ remover.Remove(project, projectReferences, settings);
+ }
+
+ ///
+ /// Lists project-to-project references.
+ ///
+ /// The context.
+ /// The list of project-to-project references.
+ ///
+ ///
+ /// var references = DotNetListReference();
+ ///
+ /// foreach (var reference in references)
+ /// {
+ /// Information(reference);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.List")]
+ public static IEnumerable DotNetListReference(this ICakeContext context)
+ {
+ return context.DotNetListReference(null);
+ }
+
+ ///
+ /// Lists project-to-project references.
+ ///
+ /// The context.
+ /// The project file to operate on. If a file is not specified, the command will search the current directory for one.
+ /// The list of project-to-project references.
+ ///
+ ///
+ /// var references = DotNetListReference("./app/app.csproj");
+ ///
+ /// foreach (var reference in references)
+ /// {
+ /// Information(reference);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.List")]
+ public static IEnumerable DotNetListReference(this ICakeContext context, string project)
+ {
+ return context.DotNetListReference(project, null);
+ }
+
+ ///
+ /// Lists project-to-project references.
+ ///
+ /// The context.
+ /// The project file to operate on. If a file is not specified, the command will search the current directory for one.
+ /// The settings.
+ /// The list of project-to-project references.
+ ///
+ ///
+ /// var settings = new DotNetReferenceListSettings
+ /// {
+ /// Verbosity = DotNetVerbosity.Diagnostic
+ /// };
+ ///
+ /// var references = DotNetListReference("./app/app.csproj", settings);
+ ///
+ /// foreach (var reference in references)
+ /// {
+ /// Information(reference);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Reference")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.List")]
+ public static IEnumerable DotNetListReference(this ICakeContext context, string project, DotNetReferenceListSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetReferenceListSettings();
+ }
+
+ var lister = new DotNetReferenceLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return lister.List(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Restore.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Restore.cs
new file mode 100644
index 0000000000..4405583f86
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Restore.cs
@@ -0,0 +1,125 @@
+// 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;
+using Cake.Common.Tools.DotNet.Restore;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// 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.
+ /// Path to the project file to restore.
+ ///
+ ///
+ /// DotNetRestore("./src/MyProject/MyProject.csproj");
+ ///
+ ///
+ [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",
+ /// DotNetVerbosity.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.
+ /// Path to the project file to restore.
+ /// 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",
+ /// DotNetVerbosity.Information,
+ /// DisableParallel = true,
+ /// InferRuntimes = new[] {"runtime1", "runtime2"}
+ /// };
+ ///
+ /// DotNetRestore("./src/MyProject/MyProject.csproj", 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 DotNetRestorer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);
+ restorer.Restore(root, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Run.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Run.cs
new file mode 100644
index 0000000000..b4b5472781
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Run.cs
@@ -0,0 +1,139 @@
+// 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;
+using Cake.Common.Tools.DotNet.Run;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Run all projects.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetRun();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Run")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
+ public static void DotNetRun(this ICakeContext context)
+ {
+ context.DotNetRun(null, null, null);
+ }
+
+ ///
+ /// Run project.
+ ///
+ /// The context.
+ /// The project path.
+ ///
+ ///
+ /// DotNetRun("./src/Project");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Run")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
+ public static void DotNetRun(this ICakeContext context, string project)
+ {
+ context.DotNetRun(project, null, null);
+ }
+
+ ///
+ /// Run project with path and arguments.
+ ///
+ /// The context.
+ /// The project path.
+ /// The arguments.
+ ///
+ ///
+ /// DotNetRun("./src/Project", "--args");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Run")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
+ public static void DotNetRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments)
+ {
+ context.DotNetRun(project, arguments, null);
+ }
+
+ ///
+ /// Run project with settings.
+ ///
+ /// The context.
+ /// The project path.
+ /// The arguments.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetRunSettings
+ /// {
+ /// Framework = "netcoreapp2.0",
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// DotNetRun("./src/Project", "--args", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Run")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
+ public static void DotNetRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments, DotNetRunSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetRunSettings();
+ }
+
+ var runner = new DotNetRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ runner.Run(project, arguments, settings);
+ }
+
+ ///
+ /// Run project with settings.
+ ///
+ /// The context.
+ /// The project path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetRunSettings
+ /// {
+ /// Framework = "netcoreapp2.0",
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// DotNetRun("./src/Project", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Run")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
+ public static void DotNetRun(this ICakeContext context, string project, DotNetRunSettings settings)
+ {
+ context.DotNetRun(project, null, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.SDK.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.SDK.cs
new file mode 100644
index 0000000000..eb5449bafa
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.SDK.cs
@@ -0,0 +1,45 @@
+// 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;
+using Cake.Common.Tools.DotNet.SDKCheck;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Lists the latest available version of the .NET SDK and .NET Runtime.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetSDKCheck();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("SDK")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.SDKCheck")]
+ public static void DotNetSDKCheck(this ICakeContext context)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var checker = new DotNetSDKChecker(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ checker.Check();
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Sln.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Sln.cs
new file mode 100644
index 0000000000..bc6322a6c5
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Sln.cs
@@ -0,0 +1,284 @@
+// 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;
+using System.Collections.Generic;
+using Cake.Common.Tools.DotNet.Sln.Add;
+using Cake.Common.Tools.DotNet.Sln.List;
+using Cake.Common.Tools.DotNet.Sln.Remove;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Lists all projects in a solution file.
+ ///
+ /// The context.
+ /// The list of projects.
+ ///
+ ///
+ /// var projects = DotNetSlnList();
+ ///
+ /// foreach (var project in projects)
+ /// {
+ /// Information(project);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.List")]
+ public static IEnumerable DotNetSlnList(this ICakeContext context)
+ {
+ return context.DotNetSlnList(null);
+ }
+
+ ///
+ /// Lists all projects in a solution file.
+ ///
+ /// The context.
+ /// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails.
+ /// The list of projects.
+ ///
+ ///
+ /// var projects = DotNetSlnList("./app/app.sln");
+ ///
+ /// foreach (var project in projects)
+ /// {
+ /// Information(project);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.List")]
+ public static IEnumerable DotNetSlnList(this ICakeContext context, FilePath solution)
+ {
+ return context.DotNetSlnList(solution, null);
+ }
+
+ ///
+ /// Lists all projects in a solution file.
+ ///
+ /// The context.
+ /// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails.
+ /// The settings.
+ /// The list of projects.
+ ///
+ ///
+ /// var settings = new DotNetSlnListSettings
+ /// {
+ /// Verbosity = DotNetVerbosity.Diagnostic
+ /// };
+ ///
+ /// var projects = DotNetSlnList("./app/app.sln");
+ ///
+ /// foreach (var project in projects)
+ /// {
+ /// Information(project);
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.List")]
+ public static IEnumerable DotNetSlnList(this ICakeContext context, FilePath solution, DotNetSlnListSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetSlnListSettings();
+ }
+
+ var lister = new DotNetSlnLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return lister.List(solution, settings);
+ }
+
+ ///
+ /// Adds one or more projects to the solution file.
+ ///
+ /// The context.
+ /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
+ ///
+ ///
+ /// DotNetSlnAdd(GetFiles("./*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
+ public static void DotNetSlnAdd(this ICakeContext context, IEnumerable projectPath)
+ {
+ context.DotNetSlnAdd(null, projectPath);
+ }
+
+ ///
+ /// Adds one or more projects to the solution file.
+ ///
+ /// The context.
+ /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
+ /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
+ ///
+ ///
+ /// DotNetSlnAdd("app.sln", GetFiles("./*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
+ public static void DotNetSlnAdd(this ICakeContext context, FilePath solution, IEnumerable projectPath)
+ {
+ context.DotNetSlnAdd(solution, projectPath, null);
+ }
+
+ ///
+ /// Adds one or more projects to the solution file.
+ ///
+ /// The context.
+ /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetSlnAddSettings
+ /// {
+ /// SolutionFolder = "libs/math"
+ /// };
+ ///
+ /// DotNetSlnAdd(GetFiles("./*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
+ public static void DotNetSlnAdd(this ICakeContext context, IEnumerable projectPath, DotNetSlnAddSettings settings)
+ {
+ context.DotNetSlnAdd(null, projectPath, settings);
+ }
+
+ ///
+ /// Adds one or more projects to the solution file.
+ ///
+ /// The context.
+ /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
+ /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetSlnAddSettings
+ /// {
+ /// SolutionFolder = "libs/math"
+ /// };
+ ///
+ /// DotNetSlnAdd("app.sln", GetFiles("./*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
+ public static void DotNetSlnAdd(this ICakeContext context, FilePath solution, IEnumerable projectPath, DotNetSlnAddSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetSlnAddSettings();
+ }
+
+ var adder = new DotNetSlnAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ adder.Add(solution, projectPath, settings);
+ }
+
+ ///
+ /// Removes a project or multiple projects from the solution file.
+ ///
+ /// The context.
+ /// The path to the project or projects to remove from the solution.
+ ///
+ ///
+ /// DotNetSlnRemove(GetFiles("./*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Remove")]
+ public static void DotNetSlnRemove(this ICakeContext context, IEnumerable projectPath)
+ {
+ context.DotNetSlnRemove(null, projectPath);
+ }
+
+ ///
+ /// Removes a project or multiple projects from the solution file.
+ ///
+ /// The context.
+ /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
+ /// The path to the project or projects to remove from the solution.
+ ///
+ ///
+ /// DotNetSlnRemove("app.sln", GetFiles("./*.csproj"));
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Remove")]
+ public static void DotNetSlnRemove(this ICakeContext context, FilePath solution, IEnumerable projectPath)
+ {
+ context.DotNetSlnRemove(solution, projectPath, null);
+ }
+
+ ///
+ /// Removes a project or multiple projects from the solution file.
+ ///
+ /// The context.
+ /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
+ /// The path to the project or projects to remove from the solution.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetSlnRemoveSettings
+ /// {
+ /// Verbosity = DotNetVerbosity.Diagnostic
+ /// };
+ ///
+ /// DotNetSlnRemove("app.sln", GetFiles("./*.csproj"), settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Sln")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Remove")]
+ public static void DotNetSlnRemove(this ICakeContext context, FilePath solution, IEnumerable projectPath, DotNetSlnRemoveSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetSlnRemoveSettings();
+ }
+
+ var remover = new DotNetSlnRemover(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ remover.Remove(solution, projectPath, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Test.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Test.cs
new file mode 100644
index 0000000000..0b71a0f7cc
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Test.cs
@@ -0,0 +1,306 @@
+// 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;
+using System.Collections.Generic;
+using Cake.Common.IO;
+using Cake.Common.Tools.DotNet.Test;
+using Cake.Common.Tools.DotNet.VSTest;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Test project.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetTest();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
+ public static void DotNetTest(this ICakeContext context)
+ {
+ context.DotNetTest(null, null, null);
+ }
+
+ ///
+ /// Test project with path.
+ ///
+ /// The context.
+ /// The project path.
+ ///
+ /// Specify the path to the .csproj file in the test project.
+ ///
+ /// DotNetTest("./test/Project.Tests/Project.Tests.csproj");
+ ///
+ /// You could also specify a task that runs multiple test projects.
+ /// Cake task:
+ ///
+ /// Task("Test")
+ /// .Does(() =>
+ /// {
+ /// var projectFiles = GetFiles("./test/**/*.csproj");
+ /// foreach(var file in projectFiles)
+ /// {
+ /// DotNetTest(file.FullPath);
+ /// }
+ /// });
+ ///
+ /// If your test project is using project.json, the project parameter should just be the directory path.
+ ///
+ /// DotNetTest("./test/Project.Tests/");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
+ public static void DotNetTest(this ICakeContext context, string project)
+ {
+ context.DotNetTest(project, null, null);
+ }
+
+ ///
+ /// Test project with settings.
+ ///
+ /// The context.
+ /// The project path.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetTestSettings
+ /// {
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// DotNetTest("./test/Project.Tests/Project.Tests.csproj", settings);
+ ///
+ /// You could also specify a task that runs multiple test projects.
+ /// Cake task:
+ ///
+ /// Task("Test")
+ /// .Does(() =>
+ /// {
+ /// var settings = new DotNetTestSettings
+ /// {
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// var projectFiles = GetFiles("./test/**/*.csproj");
+ /// foreach(var file in projectFiles)
+ /// {
+ /// DotNetTest(file.FullPath, settings);
+ /// }
+ /// });
+ ///
+ /// If your test project is using project.json, the project parameter should just be the directory path.
+ ///
+ /// var settings = new DotNetTestSettings
+ /// {
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// DotNetTest("./test/Project.Tests/", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
+ public static void DotNetTest(this ICakeContext context, string project, DotNetTestSettings settings)
+ {
+ context.DotNetTest(project, null, settings);
+ }
+
+ ///
+ /// Test project with settings.
+ ///
+ /// The context.
+ /// The project path.
+ /// The arguments.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetTestSettings
+ /// {
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// DotNetTest("./test/Project.Tests/Project.Tests.csproj", settings);
+ ///
+ /// You could also specify a task that runs multiple test projects.
+ /// Cake task:
+ ///
+ /// Task("Test")
+ /// .Does(() =>
+ /// {
+ /// var settings = new DotNetTestSettings
+ /// {
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// var projectFiles = GetFiles("./test/**/*.csproj");
+ /// foreach(var file in projectFiles)
+ /// {
+ /// DotNetTest(file.FullPath, "MSTest.MapInconclusiveToFailed=true", settings);
+ /// }
+ /// });
+ ///
+ /// If your test project is using project.json, the project parameter should just be the directory path.
+ ///
+ /// var settings = new DotNetTestSettings
+ /// {
+ /// Configuration = "Release"
+ /// };
+ ///
+ /// DotNetTest("./test/Project.Tests/", "MSTest.MapInconclusiveToFailed=true", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
+ public static void DotNetTest(this ICakeContext context, string project, ProcessArgumentBuilder arguments, DotNetTestSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetTestSettings();
+ }
+
+ var tester = new DotNetTester(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ tester.Test(project, arguments, settings);
+ }
+
+ ///
+ /// Test one or more projects specified by a path or glob pattern using the VS Test host runner.
+ ///
+ /// The context.
+ /// A path to the test file or glob for one or more test files.
+ ///
+ /// Specify the path to the .csproj file in the test project.
+ ///
+ /// DotNetVSTest("./test/Project.Tests/bin/Release/netcoreapp2.1/Project.Tests.dll");
+ ///
+ /// You could also specify a glob pattern to run multiple test projects.
+ ///
+ /// DotNetVSTest("./**/bin/Release/netcoreapp2.1/*.Tests.dll");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.VSTest")]
+ public static void DotNetVSTest(this ICakeContext context, GlobPattern testFile) => context.DotNetVSTest(testFile, null);
+
+ ///
+ /// Test one or more projects specified by a path or glob pattern with settings using the VS Test host runner.
+ ///
+ /// The context.
+ /// A path to the test file or glob for one or more test files.
+ /// The settings.
+ ///
+ /// Specify the path to the .csproj file in the test project.
+ ///
+ /// var settings = new DotNetVSTestSettings
+ /// {
+ /// Framework = "FrameworkCore10",
+ /// Platform = "x64"
+ /// };
+ ///
+ /// DotNetTest("./test/Project.Tests/bin/Release/netcoreapp2.1/Project.Tests.dll", settings);
+ ///
+ /// You could also specify a glob pattern to run multiple test projects.
+ ///
+ /// var settings = new DotNetVSTestSettings
+ /// {
+ /// Framework = "FrameworkCore10",
+ /// Platform = "x64",
+ /// Parallel = true
+ /// };
+ ///
+ /// DotNetVSTest("./**/bin/Release/netcoreapp2.1/*.Tests.dll", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.VSTest")]
+ public static void DotNetVSTest(this ICakeContext context, GlobPattern testFile, DotNetVSTestSettings settings)
+ {
+ var testFiles = context.GetFiles(testFile);
+
+ context.DotNetVSTest(testFiles, settings);
+ }
+
+ ///
+ /// Test one or more specified projects with settings using the VS Test host runner.
+ ///
+ /// The context.
+ /// The project paths to test.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetVSTestSettings
+ /// {
+ /// Framework = "FrameworkCore10",
+ /// Platform = "x64"
+ /// };
+ ///
+ /// DotNetVSTest(new[] { (FilePath)"./test/Project.Tests/bin/Release/netcoreapp2.1/Project.Tests.dll" }, settings);
+ ///
+ /// You could also specify a task that runs multiple test projects.
+ /// Cake task:
+ ///
+ /// Task("Test")
+ /// .Does(() =>
+ /// {
+ /// var settings = new DotNetVSTestSettings
+ /// {
+ /// Framework = "FrameworkCore10",
+ /// Platform = "x64",
+ /// Parallel = true
+ /// };
+ ///
+ /// var testFiles = GetFiles("./test/**/bin/Release/netcoreapp2.1/*.Test.dll");
+ ///
+ /// DotNetVSTest(testFiles, settings);
+ /// });
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Test")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.VSTest")]
+ public static void DotNetVSTest(this ICakeContext context, IEnumerable testFiles, DotNetVSTestSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetVSTestSettings();
+ }
+
+ var tester = new DotNetVSTester(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ tester.Test(testFiles, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Tool.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Tool.cs
new file mode 100644
index 0000000000..52c8600ecc
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Tool.cs
@@ -0,0 +1,162 @@
+// 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;
+using Cake.Common.Tools.DotNet.Tool;
+using Cake.Core;
+using Cake.Core.Annotations;
+using Cake.Core.IO;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Execute an .NET Core Extensibility Tool.
+ ///
+ /// The context.
+ /// The command to execute.
+ ///
+ ///
+ /// DotNetTool("cake");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Tool")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
+ public static void DotNetTool(this ICakeContext context, string command)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var arguments = new ProcessArgumentBuilder();
+ var settings = new DotNetToolSettings();
+
+ context.DotNetTool(null, command, arguments, settings);
+ }
+
+ ///
+ /// Execute an .NET Core Extensibility Tool.
+ ///
+ /// The context.
+ /// The command to execute.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetToolSettings
+ /// {
+ /// DiagnosticOutput = true
+ /// };
+ ///
+ /// DotNetTool("cake", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Tool")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
+ public static void DotNetTool(this ICakeContext context, string command, DotNetToolSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var arguments = new ProcessArgumentBuilder();
+
+ context.DotNetTool(null, command, arguments, settings);
+ }
+
+ ///
+ /// Execute an .NET Core Extensibility Tool.
+ ///
+ /// The context.
+ /// The project path.
+ /// The command to execute.
+ ///
+ ///
+ /// DotNetTool("./src/project", "xunit", "-xml report.xml");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Tool")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
+ public static void DotNetTool(this ICakeContext context, FilePath projectPath, string command)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var arguments = new ProcessArgumentBuilder();
+ var settings = new DotNetToolSettings();
+
+ context.DotNetTool(projectPath, command, arguments, settings);
+ }
+
+ ///
+ /// Execute an .NET Core Extensibility Tool.
+ ///
+ /// The context.
+ /// The project path.
+ /// The command to execute.
+ /// The arguments.
+ ///
+ ///
+ /// DotNetTool("./src/project", "xunit", "-xml report.xml");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Tool")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
+ public static void DotNetTool(this ICakeContext context, FilePath projectPath, string command, ProcessArgumentBuilder arguments)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var settings = new DotNetToolSettings();
+
+ context.DotNetTool(projectPath, command, arguments, settings);
+ }
+
+ ///
+ /// Execute an .NET Core Extensibility Tool.
+ ///
+ /// The context.
+ /// The project path.
+ /// The command to execute.
+ /// The arguments.
+ /// The settings.
+ ///
+ ///
+ /// DotNetTool("./src/project", "xunit", "-xml report.xml");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Tool")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
+ public static void DotNetTool(this ICakeContext context, FilePath projectPath, string command, ProcessArgumentBuilder arguments, DotNetToolSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var runner = new DotNetToolRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+
+ runner.Execute(projectPath, command, arguments, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.Workload.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.Workload.cs
new file mode 100644
index 0000000000..43fc1cf597
--- /dev/null
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.Workload.cs
@@ -0,0 +1,477 @@
+// 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;
+using System.Collections.Generic;
+using Cake.Common.Tools.DotNet.Workload.Install;
+using Cake.Common.Tools.DotNet.Workload.List;
+using Cake.Common.Tools.DotNet.Workload.Repair;
+using Cake.Common.Tools.DotNet.Workload.Restore;
+using Cake.Common.Tools.DotNet.Workload.Search;
+using Cake.Common.Tools.DotNet.Workload.Uninstall;
+using Cake.Common.Tools.DotNet.Workload.Update;
+using Cake.Core;
+using Cake.Core.Annotations;
+
+namespace Cake.Common.Tools.DotNet
+{
+ ///
+ /// Contains functionality related to .NET CLI.
+ ///
+ /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where
+ /// the Cake script is being executed. See this page for information
+ /// on how to install.
+ ///
+ ///
+ public static partial class DotNetAliases
+ {
+ ///
+ /// Lists available workloads.
+ ///
+ /// The context.
+ /// The list of available workloads.
+ ///
+ ///
+ /// var workloads = DotNetWorkloadSearch();
+ ///
+ /// foreach (var workload in workloads)
+ /// {
+ /// Information($"Id: {workload.Id}, Description: {workload.Description}");
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Search")]
+ public static IEnumerable DotNetWorkloadSearch(this ICakeContext context)
+ {
+ return context.DotNetWorkloadSearch(null);
+ }
+
+ ///
+ /// Lists available workloads by specifying all or part of the workload ID.
+ ///
+ /// The context.
+ /// The workload ID to search for, or part of it.
+ /// The list of available workloads.
+ ///
+ ///
+ /// var workloads = DotNetWorkloadSearch("maui");
+ ///
+ /// foreach (var workload in workloads)
+ /// {
+ /// Information($"Id: {workload.Id}, Description: {workload.Description}");
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Search")]
+ public static IEnumerable DotNetWorkloadSearch(this ICakeContext context, string searchString)
+ {
+ return context.DotNetWorkloadSearch(searchString, null);
+ }
+
+ ///
+ /// Lists available workloads by specifying all or part of the workload ID.
+ ///
+ /// The context.
+ /// The workload ID to search for, or part of it.
+ /// The settings.
+ /// The list of available workloads.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadSearchSettings
+ /// {
+ /// DotNetVerbosity.Detailed
+ /// };
+ ///
+ /// var workloads = DotNetWorkloadSearch("maui", settings);
+ ///
+ /// foreach (var workload in workloads)
+ /// {
+ /// Information($"Id: {workload.Id}, Description: {workload.Description}");
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Search")]
+ public static IEnumerable DotNetWorkloadSearch(this ICakeContext context, string searchString, DotNetWorkloadSearchSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetWorkloadSearchSettings();
+ }
+
+ var searcher = new DotNetWorkloadSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return searcher.Search(searchString, settings);
+ }
+
+ ///
+ /// Uninstalls a specified workload.
+ ///
+ /// The context.
+ /// The workload ID to uninstall.
+ ///
+ ///
+ /// DotNetWorkloadUninstall("maui");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Uninstall")]
+ public static void DotNetWorkloadUninstall(this ICakeContext context, string workloadId)
+ {
+ context.DotNetWorkloadUninstall(new string[] { workloadId });
+ }
+
+ ///
+ /// Uninstalls one or more workloads.
+ ///
+ /// The context.
+ /// The workload ID or multiple IDs to uninstall.
+ ///
+ ///
+ /// DotNetWorkloadUninstall(new string[] { "maui", "maui-desktop", "maui-mobile" });
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Uninstall")]
+ public static void DotNetWorkloadUninstall(this ICakeContext context, IEnumerable workloadIds)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ var uninstaller = new DotNetWorkloadUninstaller(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ uninstaller.Uninstall(workloadIds);
+ }
+
+ ///
+ /// Installs a specified optional workload.
+ ///
+ /// The context.
+ /// The workload ID to install.
+ ///
+ ///
+ /// DotNetWorkloadInstall("maui");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
+ public static void DotNetWorkloadInstall(this ICakeContext context, string workloadId)
+ {
+ context.DotNetWorkloadInstall(workloadId, null);
+ }
+
+ ///
+ /// Installs a specified optional workload.
+ ///
+ /// The context.
+ /// The workload ID to install.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadInstallSettings
+ /// {
+ /// IncludePreviews = true,
+ /// NoCache = true
+ /// };
+ ///
+ /// DotNetWorkloadInstall("maui", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
+ public static void DotNetWorkloadInstall(this ICakeContext context, string workloadId, DotNetWorkloadInstallSettings settings)
+ {
+ context.DotNetWorkloadInstall(new string[] { workloadId }, settings);
+ }
+
+ ///
+ /// Installs one or more optional workloads.
+ ///
+ /// The context.
+ /// The workload ID or multiple IDs to install.
+ ///
+ ///
+ /// DotNetWorkloadInstall(new string[] { "maui", "maui-desktop", "maui-mobile" });
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
+ public static void DotNetWorkloadInstall(this ICakeContext context, IEnumerable workloadIds)
+ {
+ context.DotNetWorkloadInstall(workloadIds, null);
+ }
+
+ ///
+ /// Installs one or more optional workloads.
+ ///
+ /// The context.
+ /// The workload ID or multiple IDs to install.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadInstallSettings
+ /// {
+ /// IncludePreviews = true,
+ /// NoCache = true
+ /// };
+ ///
+ /// DotNetWorkloadInstall(new string[] { "maui", "maui-desktop", "maui-mobile" }, settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
+ public static void DotNetWorkloadInstall(this ICakeContext context, IEnumerable workloadIds, DotNetWorkloadInstallSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetWorkloadInstallSettings();
+ }
+
+ var installer = new DotNetWorkloadInstaller(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ installer.Install(workloadIds, settings);
+ }
+
+ ///
+ /// Lists all installed workloads.
+ ///
+ /// The context.
+ /// The list of installed workloads.
+ ///
+ ///
+ /// var workloadIds = DotNetWorkloadList();
+ ///
+ /// foreach (var workloadId in workloadIds)
+ /// {
+ /// Information($"Installed Workload Id: {workloadId}");
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.List")]
+ public static IEnumerable DotNetWorkloadList(this ICakeContext context)
+ {
+ return context.DotNetWorkloadList(null);
+ }
+
+ ///
+ /// Lists all installed workloads.
+ ///
+ /// The context.
+ /// The settings.
+ /// The list of installed workloads.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadListSettings
+ /// {
+ /// Verbosity = DotNetVerbosity.Detailed
+ /// };
+ ///
+ /// var workloads = DotNetWorkloadList(settings);
+ ///
+ /// foreach (var workload in workloads)
+ /// {
+ /// Information($"Installed Workload Id: {workload.Id}\t Manifest Version: {workload.ManifestVersion}\t Installation Source: {workload.InstallationSource}");
+ /// }
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.List")]
+ public static IEnumerable DotNetWorkloadList(this ICakeContext context, DotNetWorkloadListSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetWorkloadListSettings();
+ }
+
+ var lister = new DotNetWorkloadLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ return lister.List(settings);
+ }
+
+ ///
+ /// Repairs all workloads installations.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetWorkloadRepair();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Repair")]
+ public static void DotNetWorkloadRepair(this ICakeContext context)
+ {
+ context.DotNetWorkloadRepair(null);
+ }
+
+ ///
+ /// Repairs all workloads installations.
+ ///
+ /// The context.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadRepairSettings
+ /// {
+ /// IncludePreviews = true,
+ /// NoCache = true
+ /// };
+ ///
+ /// DotNetWorkloadRepair(settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Repair")]
+ public static void DotNetWorkloadRepair(this ICakeContext context, DotNetWorkloadRepairSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetWorkloadRepairSettings();
+ }
+
+ var repairer = new DotNetWorkloadRepairer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ repairer.Repair(settings);
+ }
+
+ ///
+ /// Updates all installed workloads to the newest available version.
+ ///
+ /// The context.
+ ///
+ ///
+ /// DotNetWorkloadUpdate();
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Update")]
+ public static void DotNetWorkloadUpdate(this ICakeContext context)
+ {
+ context.DotNetWorkloadUpdate(null);
+ }
+
+ ///
+ /// Updates all installed workloads to the newest available version.
+ ///
+ /// The context.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadUpdateSettings
+ /// {
+ /// IncludePreviews = true,
+ /// NoCache = true
+ /// };
+ ///
+ /// DotNetWorkloadUpdate(settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Update")]
+ public static void DotNetWorkloadUpdate(this ICakeContext context, DotNetWorkloadUpdateSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings == null)
+ {
+ settings = new DotNetWorkloadUpdateSettings();
+ }
+
+ var updater = new DotNetWorkloadUpdater(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ updater.Update(settings);
+ }
+
+ ///
+ /// Installs workloads needed for a project or a solution.
+ ///
+ /// The context.
+ /// The project or solution file to install workloads for.
+ ///
+ ///
+ /// DotNetWorkloadRestore("./src/project");
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Restore")]
+ public static void DotNetWorkloadRestore(this ICakeContext context, string project)
+ {
+ context.DotNetWorkloadRestore(project, null);
+ }
+
+ ///
+ /// Installs workloads needed for a project or a solution.
+ ///
+ /// The context.
+ /// The project or solution file to install workloads for.
+ /// The settings.
+ ///
+ ///
+ /// var settings = new DotNetWorkloadRestoreSettings
+ /// {
+ /// IncludePreviews = true,
+ /// NoCache = true
+ /// };
+ ///
+ /// DotNetWorkloadRestore("./src/project", settings);
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Workload")]
+ [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Restore")]
+ public static void DotNetWorkloadRestore(this ICakeContext context, string project, DotNetWorkloadRestoreSettings settings)
+ {
+ if (context is null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (settings is null)
+ {
+ settings = new DotNetWorkloadRestoreSettings();
+ }
+
+ var restorer = new DotNetWorkloadRestorer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
+ restorer.Restore(project, settings);
+ }
+ }
+}
diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
index 49303c6547..9655c8f907 100644
--- a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
+++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs
@@ -2,46 +2,7 @@
// 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;
-using System.Collections.Generic;
-using Cake.Common.IO;
-using Cake.Common.Tools.DotNet.Build;
-using Cake.Common.Tools.DotNet.BuildServer;
-using Cake.Common.Tools.DotNet.Clean;
-using Cake.Common.Tools.DotNet.Execute;
-using Cake.Common.Tools.DotNet.Format;
-using Cake.Common.Tools.DotNet.MSBuild;
-using Cake.Common.Tools.DotNet.NuGet.Delete;
-using Cake.Common.Tools.DotNet.NuGet.Push;
-using Cake.Common.Tools.DotNet.NuGet.Source;
-using Cake.Common.Tools.DotNet.Pack;
-using Cake.Common.Tools.DotNet.Package.Add;
-using Cake.Common.Tools.DotNet.Package.List;
-using Cake.Common.Tools.DotNet.Package.Remove;
-using Cake.Common.Tools.DotNet.Package.Search;
-using Cake.Common.Tools.DotNet.Publish;
-using Cake.Common.Tools.DotNet.Reference.Add;
-using Cake.Common.Tools.DotNet.Reference.List;
-using Cake.Common.Tools.DotNet.Reference.Remove;
-using Cake.Common.Tools.DotNet.Restore;
-using Cake.Common.Tools.DotNet.Run;
-using Cake.Common.Tools.DotNet.SDKCheck;
-using Cake.Common.Tools.DotNet.Sln.Add;
-using Cake.Common.Tools.DotNet.Sln.List;
-using Cake.Common.Tools.DotNet.Sln.Remove;
-using Cake.Common.Tools.DotNet.Test;
-using Cake.Common.Tools.DotNet.Tool;
-using Cake.Common.Tools.DotNet.VSTest;
-using Cake.Common.Tools.DotNet.Workload.Install;
-using Cake.Common.Tools.DotNet.Workload.List;
-using Cake.Common.Tools.DotNet.Workload.Repair;
-using Cake.Common.Tools.DotNet.Workload.Restore;
-using Cake.Common.Tools.DotNet.Workload.Search;
-using Cake.Common.Tools.DotNet.Workload.Uninstall;
-using Cake.Common.Tools.DotNet.Workload.Update;
-using Cake.Core;
using Cake.Core.Annotations;
-using Cake.Core.IO;
namespace Cake.Common.Tools.DotNet
{
@@ -54,3095 +15,7 @@ namespace Cake.Common.Tools.DotNet
///
///
[CakeAliasCategory("DotNet")]
- public static class DotNetAliases
+ public static partial class DotNetAliases
{
- ///
- /// Execute an assembly.
- ///
- /// The context.
- /// The assembly path.
- ///
- ///
- /// DotNetExecute("./bin/Debug/app.dll");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Execute")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")]
- public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath)
- {
- context.DotNetExecute(assemblyPath, null);
- }
-
- ///
- /// Execute an assembly with arguments in the specific path.
- ///
- /// The context.
- /// The assembly path.
- /// The arguments.
- ///
- ///
- /// DotNetExecute("./bin/Debug/app.dll", "--arg");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Execute")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")]
- public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments)
- {
- context.DotNetExecute(assemblyPath, arguments, null);
- }
-
- ///
- /// Execute an assembly with arguments in the specific path with settings.
- ///
- /// The context.
- /// The assembly path.
- /// The arguments.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetExecuteSettings
- /// {
- /// FrameworkVersion = "1.0.3"
- /// };
- ///
- /// DotNetExecute("./bin/Debug/app.dll", "--arg", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Execute")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")]
- public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath, ProcessArgumentBuilder arguments, DotNetExecuteSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (assemblyPath is null)
- {
- throw new ArgumentNullException(nameof(assemblyPath));
- }
-
- if (settings is null)
- {
- settings = new DotNetExecuteSettings();
- }
-
- var executor = new DotNetExecutor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- 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.
- /// Path to the project file to restore.
- ///
- ///
- /// DotNetRestore("./src/MyProject/MyProject.csproj");
- ///
- ///
- [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",
- /// DotNetVerbosity.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.
- /// Path to the project file to restore.
- /// 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",
- /// DotNetVerbosity.Information,
- /// DisableParallel = true,
- /// InferRuntimes = new[] {"runtime1", "runtime2"}
- /// };
- ///
- /// DotNetRestore("./src/MyProject/MyProject.csproj", 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 DotNetRestorer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);
- restorer.Restore(root, settings);
- }
-
- ///
- /// Build all projects.
- ///
- /// The context.
- /// The projects path.
- ///
- ///
- /// DotNetBuild("./src/*");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Build")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Build")]
- public static void DotNetBuild(this ICakeContext context, string project)
- {
- context.DotNetBuild(project, null);
- }
-
- ///
- /// Build all projects.
- ///
- /// The context.
- /// The projects path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetBuildSettings
- /// {
- /// Framework = "netcoreapp2.0",
- /// Configuration = "Debug",
- /// OutputDirectory = "./artifacts/"
- /// };
- ///
- /// DotNetBuild("./src/*", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Build")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Build")]
- public static void DotNetBuild(this ICakeContext context, string project, DotNetBuildSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetBuildSettings();
- }
-
- var builder = new DotNetBuilder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- builder.Build(project, settings);
- }
-
- ///
- /// Publish all projects.
- ///
- /// The context.
- /// The projects path.
- ///
- ///
- /// DotNetPublish("./src/*");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Publish")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Publish")]
- public static void DotNetPublish(this ICakeContext context, string project)
- {
- context.DotNetPublish(project, null);
- }
-
- ///
- /// Publish all projects.
- ///
- /// The context.
- /// The projects path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetPublishSettings
- /// {
- /// Framework = "netcoreapp2.0",
- /// Configuration = "Release",
- /// OutputDirectory = "./artifacts/"
- /// };
- ///
- /// DotNetPublish("./src/*", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Publish")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Publish")]
- public static void DotNetPublish(this ICakeContext context, string project, DotNetPublishSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetPublishSettings();
- }
-
- var publisher = new DotNetPublisher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- publisher.Publish(project, settings);
- }
-
- ///
- /// Test project.
- ///
- /// The context.
- ///
- ///
- /// DotNetTest();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
- public static void DotNetTest(this ICakeContext context)
- {
- context.DotNetTest(null, null, null);
- }
-
- ///
- /// Test project with path.
- ///
- /// The context.
- /// The project path.
- ///
- /// Specify the path to the .csproj file in the test project.
- ///
- /// DotNetTest("./test/Project.Tests/Project.Tests.csproj");
- ///
- /// You could also specify a task that runs multiple test projects.
- /// Cake task:
- ///
- /// Task("Test")
- /// .Does(() =>
- /// {
- /// var projectFiles = GetFiles("./test/**/*.csproj");
- /// foreach(var file in projectFiles)
- /// {
- /// DotNetTest(file.FullPath);
- /// }
- /// });
- ///
- /// If your test project is using project.json, the project parameter should just be the directory path.
- ///
- /// DotNetTest("./test/Project.Tests/");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
- public static void DotNetTest(this ICakeContext context, string project)
- {
- context.DotNetTest(project, null, null);
- }
-
- ///
- /// Test project with settings.
- ///
- /// The context.
- /// The project path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetTestSettings
- /// {
- /// Configuration = "Release"
- /// };
- ///
- /// DotNetTest("./test/Project.Tests/Project.Tests.csproj", settings);
- ///
- /// You could also specify a task that runs multiple test projects.
- /// Cake task:
- ///
- /// Task("Test")
- /// .Does(() =>
- /// {
- /// var settings = new DotNetTestSettings
- /// {
- /// Configuration = "Release"
- /// };
- ///
- /// var projectFiles = GetFiles("./test/**/*.csproj");
- /// foreach(var file in projectFiles)
- /// {
- /// DotNetTest(file.FullPath, settings);
- /// }
- /// });
- ///
- /// If your test project is using project.json, the project parameter should just be the directory path.
- ///
- /// var settings = new DotNetTestSettings
- /// {
- /// Configuration = "Release"
- /// };
- ///
- /// DotNetTest("./test/Project.Tests/", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
- public static void DotNetTest(this ICakeContext context, string project, DotNetTestSettings settings)
- {
- context.DotNetTest(project, null, settings);
- }
-
- ///
- /// Test project with settings.
- ///
- /// The context.
- /// The project path.
- /// The arguments.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetTestSettings
- /// {
- /// Configuration = "Release"
- /// };
- ///
- /// DotNetTest("./test/Project.Tests/Project.Tests.csproj", settings);
- ///
- /// You could also specify a task that runs multiple test projects.
- /// Cake task:
- ///
- /// Task("Test")
- /// .Does(() =>
- /// {
- /// var settings = new DotNetTestSettings
- /// {
- /// Configuration = "Release"
- /// };
- ///
- /// var projectFiles = GetFiles("./test/**/*.csproj");
- /// foreach(var file in projectFiles)
- /// {
- /// DotNetTest(file.FullPath, "MSTest.MapInconclusiveToFailed=true", settings);
- /// }
- /// });
- ///
- /// If your test project is using project.json, the project parameter should just be the directory path.
- ///
- /// var settings = new DotNetTestSettings
- /// {
- /// Configuration = "Release"
- /// };
- ///
- /// DotNetTest("./test/Project.Tests/", "MSTest.MapInconclusiveToFailed=true", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Test")]
- public static void DotNetTest(this ICakeContext context, string project, ProcessArgumentBuilder arguments, DotNetTestSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetTestSettings();
- }
-
- var tester = new DotNetTester(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- tester.Test(project, arguments, settings);
- }
-
- ///
- /// Cleans a project's output.
- ///
- /// The context.
- /// The project's path.
- ///
- ///
- /// DotNetClean("./src/project");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Clean")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Clean")]
- public static void DotNetClean(this ICakeContext context, string project)
- {
- context.DotNetClean(project, null);
- }
-
- ///
- /// Cleans a project's output.
- ///
- /// The context.
- /// The projects path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetCleanSettings
- /// {
- /// Framework = "netcoreapp2.0",
- /// Configuration = "Debug",
- /// OutputDirectory = "./artifacts/"
- /// };
- ///
- /// DotNetClean("./src/project", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Clean")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Clean")]
- public static void DotNetClean(this ICakeContext context, string project, DotNetCleanSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetCleanSettings();
- }
-
- var cleaner = new DotNetCleaner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- cleaner.Clean(project, settings);
- }
-
- ///
- /// Delete a NuGet Package from a server.
- ///
- /// The context.
- ///
- ///
- /// DotNetNuGetDelete();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
- public static void DotNetNuGetDelete(this ICakeContext context)
- {
- context.DotNetNuGetDelete(null, null, null);
- }
-
- ///
- /// Deletes a package from nuget.org.
- ///
- /// The context.
- /// Name of package to delete.
- ///
- ///
- /// DotNetNuGetDelete("Microsoft.AspNetCore.Mvc");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
- public static void DotNetNuGetDelete(this ICakeContext context, string packageName)
- {
- context.DotNetNuGetDelete(packageName, null, null);
- }
-
- ///
- /// Deletes a specific version of a package from nuget.org.
- ///
- /// The context.
- /// Name of package to delete.
- /// Version of package to delete.
- ///
- ///
- /// DotNetRestore("Microsoft.AspNetCore.Mvc", "1.0");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
- public static void DotNetNuGetDelete(this ICakeContext context, string packageName, string packageVersion)
- {
- context.DotNetNuGetDelete(packageName, packageVersion, null);
- }
-
- ///
- /// Deletes a package from a server.
- ///
- /// The context.
- /// Name of package to delete.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetDeleteSettings
- /// {
- /// Source = "https://www.example.com/nugetfeed",
- /// NonInteractive = true
- /// };
- ///
- /// DotNetNuGetDelete("Microsoft.AspNetCore.Mvc", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
- public static void DotNetNuGetDelete(this ICakeContext context, string packageName, DotNetNuGetDeleteSettings settings)
- {
- context.DotNetNuGetDelete(packageName, null, settings);
- }
-
- ///
- /// Deletes a package from a server using the specified settings.
- ///
- /// The context.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetDeleteSettings
- /// {
- /// Source = "https://www.example.com/nugetfeed",
- /// NonInteractive = true
- /// };
- ///
- /// DotNetNuGetDelete(settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
- public static void DotNetNuGetDelete(this ICakeContext context, DotNetNuGetDeleteSettings settings)
- {
- context.DotNetNuGetDelete(null, null, settings);
- }
-
- ///
- /// Deletes a package from a server using the specified settings.
- ///
- /// The context.
- /// Name of package to delete.
- /// Version of package to delete.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetDeleteSettings
- /// {
- /// Source = "https://www.example.com/nugetfeed",
- /// NonInteractive = true
- /// };
- ///
- /// DotNetNuGetDelete("Microsoft.AspNetCore.Mvc", "1.0", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Delete")]
- public static void DotNetNuGetDelete(this ICakeContext context, string packageName, string packageVersion, DotNetNuGetDeleteSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetNuGetDeleteSettings();
- }
-
- var nugetDeleter = new DotNetNuGetDeleter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- nugetDeleter.Delete(packageName, packageVersion, settings);
- }
-
- ///
- /// Pushes one or more packages to a server.
- ///
- /// The context.
- /// of the package to push.
- ///
- ///
- /// // With FilePath instance
- /// var packageFilePath = GetFiles("*.nupkg").Single();
- /// DotNetNuGetPush(packageFilePath);
- /// // With string parameter
- /// DotNetNuGetPush("foo*.nupkg");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Push")]
- public static void DotNetNuGetPush(this ICakeContext context, FilePath packageFilePath)
- {
- context.DotNetNuGetPush(packageFilePath, null);
- }
-
- ///
- /// Pushes one or more packages to a server using the specified settings.
- ///
- /// The context.
- /// of the package to push.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetPushSettings
- /// {
- /// Source = "https://www.example.com/nugetfeed",
- /// ApiKey = "4003d786-cc37-4004-bfdf-c4f3e8ef9b3a"
- /// };
- /// // With FilePath instance
- /// var packageFilePath = GetFiles("foo*.nupkg").Single();
- /// DotNetNuGetPush(packageFilePath);
- /// // With string parameter
- /// DotNetNuGetPush("foo*.nupkg", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Push")]
- public static void DotNetNuGetPush(this ICakeContext context, FilePath packageFilePath, DotNetNuGetPushSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetNuGetPushSettings();
- }
-
- var restorer = new DotNetNuGetPusher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- restorer.Push(packageFilePath?.FullPath, settings);
- }
-
- ///
- /// Add the specified NuGet source.
- ///
- /// The context.
- /// The name of the source.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetSourceSettings
- /// {
- /// Source = "https://www.example.com/nugetfeed",
- /// UserName = "username",
- /// Password = "password",
- /// StorePasswordInClearText = true,
- /// ValidAuthenticationTypes = "basic,negotiate"
- /// };
- ///
- /// DotNetNuGetAddSource("example", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static void DotNetNuGetAddSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- 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 DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- sourcer.DisableSource(name, settings ?? new DotNetNuGetSourceSettings());
- }
-
- ///
- /// Enable the specified NuGet source.
- ///
- /// The context.
- /// The name of the source.
- ///
- ///
- /// DotNetNuGetEnableSource("example");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static void DotNetNuGetEnableSource(this ICakeContext context, string name)
- {
- context.DotNetNuGetEnableSource(name, null);
- }
-
- ///
- /// Enable the specified NuGet source.
- ///
- /// The context.
- /// The name of the source.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetSourceSettings
- /// {
- /// ConfigFile = "NuGet.config"
- /// };
- ///
- /// DotNetNuGetEnableSource("example", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static void DotNetNuGetEnableSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- sourcer.EnableSource(name, settings ?? new DotNetNuGetSourceSettings());
- }
-
- ///
- /// Determines whether the specified NuGet source exists.
- ///
- /// The context.
- /// The name of the source.
- /// Whether the specified NuGet source exists.
- ///
- ///
- /// var exists = DotNetNuGetHasSource("example");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static bool DotNetNuGetHasSource(this ICakeContext context, string name)
- {
- return context.DotNetNuGetHasSource(name, null);
- }
-
- ///
- /// Determines whether the specified NuGet source exists.
- ///
- /// The context.
- /// The name of the source.
- /// The settings.
- /// Whether the specified NuGet source exists.
- ///
- ///
- /// var settings = new DotNetNuGetSourceSettings
- /// {
- /// ConfigFile = "NuGet.config"
- /// };
- ///
- /// var exists = DotNetNuGetHasSource("example", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static bool DotNetNuGetHasSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return sourcer.HasSource(name, settings ?? new DotNetNuGetSourceSettings());
- }
-
- ///
- /// Remove the specified NuGet source.
- ///
- /// The context.
- /// The name of the source.
- ///
- ///
- /// DotNetNuGetRemoveSource("example");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static void DotNetNuGetRemoveSource(this ICakeContext context, string name)
- {
- context.DotNetNuGetRemoveSource(name, null);
- }
-
- ///
- /// Remove the specified NuGet source.
- ///
- /// The context.
- /// The name of the source.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetSourceSettings
- /// {
- /// ConfigFile = "NuGet.config"
- /// };
- ///
- /// DotNetNuGetRemoveSource("example", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static void DotNetNuGetRemoveSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- sourcer.RemoveSource(name, settings ?? new DotNetNuGetSourceSettings());
- }
-
- ///
- /// Update the specified NuGet source.
- ///
- /// The context.
- /// The name of the source.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetNuGetSourceSettings
- /// {
- /// Source = "https://www.example.com/nugetfeed",
- /// UserName = "username",
- /// Password = "password",
- /// StorePasswordInClearText = true,
- /// ValidAuthenticationTypes = "basic,negotiate"
- /// };
- ///
- /// DotNetNuGetUpdateSource("example", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("NuGet")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.NuGet.Source")]
- public static void DotNetNuGetUpdateSource(this ICakeContext context, string name, DotNetNuGetSourceSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var sourcer = new DotNetNuGetSourcer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- sourcer.UpdateSource(name, settings);
- }
-
- ///
- /// Package all projects.
- ///
- /// The context.
- /// The projects path.
- ///
- ///
- /// DotNetPack("./src/*");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Pack")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Pack")]
- public static void DotNetPack(this ICakeContext context, string project)
- {
- context.DotNetPack(project, null);
- }
-
- ///
- /// Package all projects.
- ///
- /// The context.
- /// The projects path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetPackSettings
- /// {
- /// Configuration = "Release",
- /// OutputDirectory = "./artifacts/"
- /// };
- ///
- /// DotNetPack("./src/*", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Pack")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Pack")]
- public static void DotNetPack(this ICakeContext context, string project, DotNetPackSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetPackSettings();
- }
-
- var packer = new DotNetPacker(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- packer.Pack(project, settings);
- }
-
- ///
- /// Run all projects.
- ///
- /// The context.
- ///
- ///
- /// DotNetRun();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Run")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
- public static void DotNetRun(this ICakeContext context)
- {
- context.DotNetRun(null, null, null);
- }
-
- ///
- /// Run project.
- ///
- /// The context.
- /// The project path.
- ///
- ///
- /// DotNetRun("./src/Project");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Run")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
- public static void DotNetRun(this ICakeContext context, string project)
- {
- context.DotNetRun(project, null, null);
- }
-
- ///
- /// Run project with path and arguments.
- ///
- /// The context.
- /// The project path.
- /// The arguments.
- ///
- ///
- /// DotNetRun("./src/Project", "--args");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Run")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
- public static void DotNetRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments)
- {
- context.DotNetRun(project, arguments, null);
- }
-
- ///
- /// Run project with settings.
- ///
- /// The context.
- /// The project path.
- /// The arguments.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetRunSettings
- /// {
- /// Framework = "netcoreapp2.0",
- /// Configuration = "Release"
- /// };
- ///
- /// DotNetRun("./src/Project", "--args", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Run")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
- public static void DotNetRun(this ICakeContext context, string project, ProcessArgumentBuilder arguments, DotNetRunSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetRunSettings();
- }
-
- var runner = new DotNetRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- runner.Run(project, arguments, settings);
- }
-
- ///
- /// Run project with settings.
- ///
- /// The context.
- /// The project path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetRunSettings
- /// {
- /// Framework = "netcoreapp2.0",
- /// Configuration = "Release"
- /// };
- ///
- /// DotNetRun("./src/Project", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Run")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Run")]
- public static void DotNetRun(this ICakeContext context, string project, DotNetRunSettings settings)
- {
- context.DotNetRun(project, null, settings);
- }
-
- ///
- /// Builds the specified targets in a project file found in the current working directory.
- ///
- /// The context.
- ///
- ///
- /// DotNetMSBuild();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("MSBuild")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
- public static void DotNetMSBuild(this ICakeContext context)
- {
- context.DotNetMSBuild(null, null);
- }
-
- ///
- /// Builds the specified targets in the project file.
- ///
- /// The context.
- /// Project file or directory to search for project file.
- ///
- ///
- /// DotNetMSBuild("foobar.proj");
- ///
- ///
- ///
- /// If a directory is specified, MSBuild searches that directory for a project file.
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("MSBuild")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
- public static void DotNetMSBuild(this ICakeContext context, string projectOrDirectory)
- {
- if (string.IsNullOrWhiteSpace(projectOrDirectory))
- {
- throw new ArgumentNullException(nameof(projectOrDirectory));
- }
-
- context.DotNetMSBuild(projectOrDirectory, null);
- }
-
- ///
- /// Builds the specified targets in a project file found in the current working directory.
- ///
- /// The context.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetMSBuildSettings
- /// {
- /// NoLogo = true,
- /// MaxCpuCount = -1
- /// };
- ///
- /// DotNetMSBuild(settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("MSBuild")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
- public static void DotNetMSBuild(this ICakeContext context, DotNetMSBuildSettings settings)
- {
- context.DotNetMSBuild(null, settings);
- }
-
- ///
- /// Builds the specified targets in the project file.
- ///
- /// The context.
- /// Project file or directory to search for project file.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetMSBuildSettings
- /// {
- /// NoLogo = true,
- /// MaxCpuCount = -1
- /// };
- ///
- /// DotNetMSBuild("foobar.proj", settings);
- ///
- ///
- ///
- /// If a project file is not specified, MSBuild searches the current working directory for a file that has a file
- /// extension that ends in "proj" and uses that file. If a directory is specified, MSBuild searches that directory for a project file.
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("MSBuild")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.MSBuild")]
- public static void DotNetMSBuild(this ICakeContext context, string projectOrDirectory, DotNetMSBuildSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetMSBuildSettings();
- }
-
- var builder = new DotNetMSBuildBuilder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- builder.Build(projectOrDirectory, settings);
- }
-
- ///
- /// Test one or more projects specified by a path or glob pattern using the VS Test host runner.
- ///
- /// The context.
- /// A path to the test file or glob for one or more test files.
- ///
- /// Specify the path to the .csproj file in the test project.
- ///
- /// DotNetVSTest("./test/Project.Tests/bin/Release/netcoreapp2.1/Project.Tests.dll");
- ///
- /// You could also specify a glob pattern to run multiple test projects.
- ///
- /// DotNetVSTest("./**/bin/Release/netcoreapp2.1/*.Tests.dll");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.VSTest")]
- public static void DotNetVSTest(this ICakeContext context, GlobPattern testFile) => context.DotNetVSTest(testFile, null);
-
- ///
- /// Test one or more projects specified by a path or glob pattern with settings using the VS Test host runner.
- ///
- /// The context.
- /// A path to the test file or glob for one or more test files.
- /// The settings.
- ///
- /// Specify the path to the .csproj file in the test project.
- ///
- /// var settings = new DotNetVSTestSettings
- /// {
- /// Framework = "FrameworkCore10",
- /// Platform = "x64"
- /// };
- ///
- /// DotNetTest("./test/Project.Tests/bin/Release/netcoreapp2.1/Project.Tests.dll", settings);
- ///
- /// You could also specify a glob pattern to run multiple test projects.
- ///
- /// var settings = new DotNetVSTestSettings
- /// {
- /// Framework = "FrameworkCore10",
- /// Platform = "x64",
- /// Parallel = true
- /// };
- ///
- /// DotNetVSTest("./**/bin/Release/netcoreapp2.1/*.Tests.dll", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.VSTest")]
- public static void DotNetVSTest(this ICakeContext context, GlobPattern testFile, DotNetVSTestSettings settings)
- {
- var testFiles = context.GetFiles(testFile);
-
- context.DotNetVSTest(testFiles, settings);
- }
-
- ///
- /// Test one or more specified projects with settings using the VS Test host runner.
- ///
- /// The context.
- /// The project paths to test.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetVSTestSettings
- /// {
- /// Framework = "FrameworkCore10",
- /// Platform = "x64"
- /// };
- ///
- /// DotNetVSTest(new[] { (FilePath)"./test/Project.Tests/bin/Release/netcoreapp2.1/Project.Tests.dll" }, settings);
- ///
- /// You could also specify a task that runs multiple test projects.
- /// Cake task:
- ///
- /// Task("Test")
- /// .Does(() =>
- /// {
- /// var settings = new DotNetVSTestSettings
- /// {
- /// Framework = "FrameworkCore10",
- /// Platform = "x64",
- /// Parallel = true
- /// };
- ///
- /// var testFiles = GetFiles("./test/**/bin/Release/netcoreapp2.1/*.Test.dll");
- ///
- /// DotNetVSTest(testFiles, settings);
- /// });
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Test")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.VSTest")]
- public static void DotNetVSTest(this ICakeContext context, IEnumerable testFiles, DotNetVSTestSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetVSTestSettings();
- }
-
- var tester = new DotNetVSTester(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- tester.Test(testFiles, settings);
- }
-
- ///
- /// Execute an .NET Core Extensibility Tool.
- ///
- /// The context.
- /// The command to execute.
- ///
- ///
- /// DotNetTool("cake");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Tool")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
- public static void DotNetTool(this ICakeContext context, string command)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var arguments = new ProcessArgumentBuilder();
- var settings = new DotNetToolSettings();
-
- context.DotNetTool(null, command, arguments, settings);
- }
-
- ///
- /// Execute an .NET Core Extensibility Tool.
- ///
- /// The context.
- /// The command to execute.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetToolSettings
- /// {
- /// DiagnosticOutput = true
- /// };
- ///
- /// DotNetTool("cake", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Tool")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
- public static void DotNetTool(this ICakeContext context, string command, DotNetToolSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var arguments = new ProcessArgumentBuilder();
-
- context.DotNetTool(null, command, arguments, settings);
- }
-
- ///
- /// Execute an .NET Core Extensibility Tool.
- ///
- /// The context.
- /// The project path.
- /// The command to execute.
- ///
- ///
- /// DotNetTool("./src/project", "xunit", "-xml report.xml");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Tool")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
- public static void DotNetTool(this ICakeContext context, FilePath projectPath, string command)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var arguments = new ProcessArgumentBuilder();
- var settings = new DotNetToolSettings();
-
- context.DotNetTool(projectPath, command, arguments, settings);
- }
-
- ///
- /// Execute an .NET Core Extensibility Tool.
- ///
- /// The context.
- /// The project path.
- /// The command to execute.
- /// The arguments.
- ///
- ///
- /// DotNetTool("./src/project", "xunit", "-xml report.xml");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Tool")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
- public static void DotNetTool(this ICakeContext context, FilePath projectPath, string command, ProcessArgumentBuilder arguments)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var settings = new DotNetToolSettings();
-
- context.DotNetTool(projectPath, command, arguments, settings);
- }
-
- ///
- /// Execute an .NET Core Extensibility Tool.
- ///
- /// The context.
- /// The project path.
- /// The command to execute.
- /// The arguments.
- /// The settings.
- ///
- ///
- /// DotNetTool("./src/project", "xunit", "-xml report.xml");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Tool")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Tool")]
- public static void DotNetTool(this ICakeContext context, FilePath projectPath, string command, ProcessArgumentBuilder arguments, DotNetToolSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var runner = new DotNetToolRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
-
- runner.Execute(projectPath, command, arguments, settings);
- }
-
- ///
- /// Shuts down build servers that are started from dotnet.
- ///
- /// The context.
- ///
- ///
- /// DotNetBuildServerShutdown();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Build Server")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.BuildServer")]
- public static void DotNetBuildServerShutdown(this ICakeContext context)
- {
- context.DotNetBuildServerShutdown(null);
- }
-
- ///
- /// Shuts down build servers that are started from dotnet.
- ///
- /// The context.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetBuildServerShutdownSettings
- /// {
- /// MSBuild = true
- /// };
- ///
- /// DotNetBuildServerShutdown(settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Build Server")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.BuildServer")]
- public static void DotNetBuildServerShutdown(this ICakeContext context, DotNetBuildServerShutdownSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var buildServer = new DotNetBuildServer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
-
- buildServer.Shutdown(settings ?? new DotNetBuildServerShutdownSettings());
- }
-
- ///
- /// Formats code to match editorconfig settings.
- ///
- /// The context.
- /// The project or solution path.
- ///
- ///
- /// DotNetFormat("./src/project");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormat(this ICakeContext context, string root)
- {
- context.DotNetFormat(root, null);
- }
-
- ///
- /// Formats code to match editorconfig settings.
- ///
- /// The context.
- /// The project or solution path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetFormatSettings
- /// {
- /// NoRestore = true,
- /// Include = "Program.cs Utility\Logging.cs",
- /// Severity = DotNetFormatSeverity.Error
- /// };
- ///
- /// DotNetFormat("./src/project", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormat(this ICakeContext context, string root, DotNetFormatSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetFormatSettings();
- }
-
- var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- formatter.Format(root, null, settings);
- }
-
- ///
- /// Format code to match editorconfig settings for whitespace.
- ///
- /// The context.
- /// The project or solution path.
- ///
- ///
- /// DotNetFormatWhitespace("./src/*");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormatWhitespace(this ICakeContext context, string root)
- {
- context.DotNetFormatWhitespace(root, null);
- }
-
- ///
- /// Format code to match editorconfig settings for whitespace.
- ///
- /// The context.
- /// The project or solution path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetFormatSettings
- /// {
- /// NoRestore = true,
- /// Include = "Program.cs Utility\Logging.cs"
- /// };
- ///
- /// DotNetFormatWhitespace("./src/*", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormatWhitespace(this ICakeContext context, string root, DotNetFormatSettings settings)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetFormatSettings();
- }
-
- var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- formatter.Format(root, "whitespace", settings);
- }
-
- ///
- /// Format code to match editorconfig settings for code style.
- ///
- /// The context.
- /// The project or solution path.
- ///
- ///
- /// DotNetFormatStyle("./src/*");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormatStyle(this ICakeContext context, string root)
- {
- context.DotNetFormatStyle(root, null);
- }
-
- ///
- /// Format code to match editorconfig settings for code style.
- ///
- /// The context.
- /// The project or solution path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetFormatSettings
- /// {
- /// NoRestore = true,
- /// Include = "Program.cs Utility\Logging.cs"
- /// };
- ///
- /// DotNetFormatStyle("./src/*", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormatStyle(this ICakeContext context, string root, DotNetFormatSettings settings)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetFormatSettings();
- }
-
- var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- formatter.Format(root, "style", settings);
- }
-
- ///
- /// Format code to match editorconfig settings for analyzers.
- ///
- /// The context.
- /// The project or solution path.
- ///
- ///
- /// DotNetFormatAnalyzers("./src/*");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormatAnalyzers(this ICakeContext context, string project)
- {
- context.DotNetFormatAnalyzers(project, null);
- }
-
- ///
- /// Format code to match editorconfig settings for analyzers.
- ///
- /// The context.
- /// The project or solution path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetFormatSettings
- /// {
- /// NoRestore = true,
- /// Include = "Program.cs Utility\Logging.cs"
- /// };
- ///
- /// DotNetFormatAnalyzers("./src/*", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Format")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Format")]
- public static void DotNetFormatAnalyzers(this ICakeContext context, string root, DotNetFormatSettings settings)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetFormatSettings();
- }
-
- var formatter = new DotNetFormatter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- formatter.Format(root, "analyzers", settings);
- }
-
- ///
- /// Lists the latest available version of the .NET SDK and .NET Runtime.
- ///
- /// The context.
- ///
- ///
- /// DotNetSDKCheck();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("SDK")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.SDKCheck")]
- public static void DotNetSDKCheck(this ICakeContext context)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var checker = new DotNetSDKChecker(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- checker.Check();
- }
-
- ///
- /// Lists available workloads.
- ///
- /// The context.
- /// The list of available workloads.
- ///
- ///
- /// var workloads = DotNetWorkloadSearch();
- ///
- /// foreach (var workload in workloads)
- /// {
- /// Information($"Id: {workload.Id}, Description: {workload.Description}");
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Search")]
- public static IEnumerable DotNetWorkloadSearch(this ICakeContext context)
- {
- return context.DotNetWorkloadSearch(null);
- }
-
- ///
- /// Lists available workloads by specifying all or part of the workload ID.
- ///
- /// The context.
- /// The workload ID to search for, or part of it.
- /// The list of available workloads.
- ///
- ///
- /// var workloads = DotNetWorkloadSearch("maui");
- ///
- /// foreach (var workload in workloads)
- /// {
- /// Information($"Id: {workload.Id}, Description: {workload.Description}");
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Search")]
- public static IEnumerable DotNetWorkloadSearch(this ICakeContext context, string searchString)
- {
- return context.DotNetWorkloadSearch(searchString, null);
- }
-
- ///
- /// Lists available workloads by specifying all or part of the workload ID.
- ///
- /// The context.
- /// The workload ID to search for, or part of it.
- /// The settings.
- /// The list of available workloads.
- ///
- ///
- /// var settings = new DotNetWorkloadSearchSettings
- /// {
- /// DotNetVerbosity.Detailed
- /// };
- ///
- /// var workloads = DotNetWorkloadSearch("maui", settings);
- ///
- /// foreach (var workload in workloads)
- /// {
- /// Information($"Id: {workload.Id}, Description: {workload.Description}");
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Search")]
- public static IEnumerable DotNetWorkloadSearch(this ICakeContext context, string searchString, DotNetWorkloadSearchSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetWorkloadSearchSettings();
- }
-
- var searcher = new DotNetWorkloadSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return searcher.Search(searchString, settings);
- }
-
- ///
- /// Uninstalls a specified workload.
- ///
- /// The context.
- /// The workload ID to uninstall.
- ///
- ///
- /// DotNetWorkloadUninstall("maui");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Uninstall")]
- public static void DotNetWorkloadUninstall(this ICakeContext context, string workloadId)
- {
- context.DotNetWorkloadUninstall(new string[] { workloadId });
- }
-
- ///
- /// Uninstalls one or more workloads.
- ///
- /// The context.
- /// The workload ID or multiple IDs to uninstall.
- ///
- ///
- /// DotNetWorkloadUninstall(new string[] { "maui", "maui-desktop", "maui-mobile" });
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Uninstall")]
- public static void DotNetWorkloadUninstall(this ICakeContext context, IEnumerable workloadIds)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var uninstaller = new DotNetWorkloadUninstaller(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- uninstaller.Uninstall(workloadIds);
- }
-
- ///
- /// Installs a specified optional workload.
- ///
- /// The context.
- /// The workload ID to install.
- ///
- ///
- /// DotNetWorkloadInstall("maui");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
- public static void DotNetWorkloadInstall(this ICakeContext context, string workloadId)
- {
- context.DotNetWorkloadInstall(workloadId, null);
- }
-
- ///
- /// Installs a specified optional workload.
- ///
- /// The context.
- /// The workload ID to install.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetWorkloadInstallSettings
- /// {
- /// IncludePreviews = true,
- /// NoCache = true
- /// };
- ///
- /// DotNetWorkloadInstall("maui", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
- public static void DotNetWorkloadInstall(this ICakeContext context, string workloadId, DotNetWorkloadInstallSettings settings)
- {
- context.DotNetWorkloadInstall(new string[] { workloadId }, settings);
- }
-
- ///
- /// Installs one or more optional workloads.
- ///
- /// The context.
- /// The workload ID or multiple IDs to install.
- ///
- ///
- /// DotNetWorkloadInstall(new string[] { "maui", "maui-desktop", "maui-mobile" });
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
- public static void DotNetWorkloadInstall(this ICakeContext context, IEnumerable workloadIds)
- {
- context.DotNetWorkloadInstall(workloadIds, null);
- }
-
- ///
- /// Installs one or more optional workloads.
- ///
- /// The context.
- /// The workload ID or multiple IDs to install.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetWorkloadInstallSettings
- /// {
- /// IncludePreviews = true,
- /// NoCache = true
- /// };
- ///
- /// DotNetWorkloadInstall(new string[] { "maui", "maui-desktop", "maui-mobile" }, settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Install")]
- public static void DotNetWorkloadInstall(this ICakeContext context, IEnumerable workloadIds, DotNetWorkloadInstallSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetWorkloadInstallSettings();
- }
-
- var installer = new DotNetWorkloadInstaller(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- installer.Install(workloadIds, settings);
- }
-
- ///
- /// Lists all installed workloads.
- ///
- /// The context.
- /// The list of installed workloads.
- ///
- ///
- /// var workloadIds = DotNetWorkloadList();
- ///
- /// foreach (var workloadId in workloadIds)
- /// {
- /// Information($"Installed Workload Id: {workloadId}");
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.List")]
- public static IEnumerable DotNetWorkloadList(this ICakeContext context)
- {
- return context.DotNetWorkloadList(null);
- }
-
- ///
- /// Lists all installed workloads.
- ///
- /// The context.
- /// The settings.
- /// The list of installed workloads.
- ///
- ///
- /// var settings = new DotNetWorkloadListSettings
- /// {
- /// Verbosity = DotNetVerbosity.Detailed
- /// };
- ///
- /// var workloads = DotNetWorkloadList(settings);
- ///
- /// foreach (var workload in workloads)
- /// {
- /// Information($"Installed Workload Id: {workload.Id}\t Manifest Version: {workload.ManifestVersion}\t Installation Source: {workload.InstallationSource}");
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.List")]
- public static IEnumerable DotNetWorkloadList(this ICakeContext context, DotNetWorkloadListSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetWorkloadListSettings();
- }
-
- var lister = new DotNetWorkloadLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return lister.List(settings);
- }
-
- ///
- /// Repairs all workloads installations.
- ///
- /// The context.
- ///
- ///
- /// DotNetWorkloadRepair();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Repair")]
- public static void DotNetWorkloadRepair(this ICakeContext context)
- {
- context.DotNetWorkloadRepair(null);
- }
-
- ///
- /// Repairs all workloads installations.
- ///
- /// The context.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetWorkloadRepairSettings
- /// {
- /// IncludePreviews = true,
- /// NoCache = true
- /// };
- ///
- /// DotNetWorkloadRepair(settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Repair")]
- public static void DotNetWorkloadRepair(this ICakeContext context, DotNetWorkloadRepairSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetWorkloadRepairSettings();
- }
-
- var repairer = new DotNetWorkloadRepairer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- repairer.Repair(settings);
- }
-
- ///
- /// Updates all installed workloads to the newest available version.
- ///
- /// The context.
- ///
- ///
- /// DotNetWorkloadUpdate();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Update")]
- public static void DotNetWorkloadUpdate(this ICakeContext context)
- {
- context.DotNetWorkloadUpdate(null);
- }
-
- ///
- /// Updates all installed workloads to the newest available version.
- ///
- /// The context.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetWorkloadUpdateSettings
- /// {
- /// IncludePreviews = true,
- /// NoCache = true
- /// };
- ///
- /// DotNetWorkloadUpdate(settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Update")]
- public static void DotNetWorkloadUpdate(this ICakeContext context, DotNetWorkloadUpdateSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings == null)
- {
- settings = new DotNetWorkloadUpdateSettings();
- }
-
- var updater = new DotNetWorkloadUpdater(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- updater.Update(settings);
- }
-
- ///
- /// Installs workloads needed for a project or a solution.
- ///
- /// The context.
- /// The project or solution file to install workloads for.
- ///
- ///
- /// DotNetWorkloadRestore("./src/project");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Restore")]
- public static void DotNetWorkloadRestore(this ICakeContext context, string project)
- {
- context.DotNetWorkloadRestore(project, null);
- }
-
- ///
- /// Installs workloads needed for a project or a solution.
- ///
- /// The context.
- /// The project or solution file to install workloads for.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetWorkloadRestoreSettings
- /// {
- /// IncludePreviews = true,
- /// NoCache = true
- /// };
- ///
- /// DotNetWorkloadRestore("./src/project", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Workload")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Workload.Restore")]
- public static void DotNetWorkloadRestore(this ICakeContext context, string project, DotNetWorkloadRestoreSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetWorkloadRestoreSettings();
- }
-
- var restorer = new DotNetWorkloadRestorer(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- restorer.Restore(project, settings);
- }
-
- ///
- /// Adds or updates a package reference in a project file.
- ///
- /// The context.
- /// The package reference to add.
- ///
- ///
- /// DotNetAddPackage("Cake.FileHelper");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
- public static void DotNetAddPackage(this ICakeContext context, string packageName)
- {
- context.DotNetAddPackage(packageName, null, null);
- }
-
- ///
- /// Adds or updates a package reference in a project file.
- ///
- /// The context.
- /// The package reference to add.
- /// The target project file path.
- ///
- ///
- /// DotNetAddPackage("Cake.FileHelper", "ToDo.csproj");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
- public static void DotNetAddPackage(this ICakeContext context, string packageName, string project)
- {
- context.DotNetAddPackage(packageName, project, null);
- }
-
- ///
- /// Adds or updates a package reference in a project file.
- ///
- /// The context.
- /// The package reference to add.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetPackageAddSettings
- /// {
- /// NoRestore = true,
- /// Version = "6.1.3"
- /// };
- ///
- /// DotNetAddPackage("Cake.FileHelper", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
- public static void DotNetAddPackage(this ICakeContext context, string packageName, DotNetPackageAddSettings settings)
- {
- context.DotNetAddPackage(packageName, null, settings);
- }
-
- ///
- /// Adds or updates a package reference in a project file.
- ///
- /// The context.
- /// The package reference to add.
- /// The target project file path.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetPackageAddSettings
- /// {
- /// NoRestore = true,
- /// Version = "6.1.3"
- /// };
- ///
- /// DotNetAddPackage("Cake.FileHelper", "ToDo.csproj", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Add")]
- public static void DotNetAddPackage(this ICakeContext context, string packageName, string project, DotNetPackageAddSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetPackageAddSettings();
- }
-
- var adder = new DotNetPackageAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- adder.Add(packageName, project, settings);
- }
-
- ///
- /// Removes package reference from a project file.
- ///
- /// The context.
- /// The package reference to remove.
- ///
- ///
- /// DotNetRemovePackage("Cake.FileHelper");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Remove")]
- public static void DotNetRemovePackage(this ICakeContext context, string packageName)
- {
- context.DotNetRemovePackage(packageName, null);
- }
-
- ///
- /// Removes package reference from a project file.
- ///
- /// The context.
- /// The package reference to remove.
- /// The target project file path.
- ///
- ///
- /// DotNetRemovePackage("Cake.FileHelper", "ToDo.csproj");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Remove")]
- public static void DotNetRemovePackage(this ICakeContext context, string packageName, string project)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- var adder = new DotNetPackageRemover(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- adder.Remove(packageName, project);
- }
-
- ///
- /// Adds project-to-project (P2P) references.
- ///
- /// The context.
- /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
- ///
- ///
- /// DotNetAddReference(GetFiles("./src/*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
- public static void DotNetAddReference(this ICakeContext context, IEnumerable projectReferences)
- {
- context.DotNetAddReference(projectReferences, null);
- }
-
- ///
- /// Adds project-to-project (P2P) references.
- ///
- /// The context.
- /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetReferenceAddSettings
- /// {
- /// Framework = "net8.0"
- /// };
- ///
- /// DotNetAddReference(GetFiles("./src/*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
- public static void DotNetAddReference(this ICakeContext context, IEnumerable projectReferences, DotNetReferenceAddSettings settings)
- {
- context.DotNetAddReference(null, projectReferences, settings);
- }
-
- ///
- /// Adds project-to-project (P2P) references.
- ///
- /// The context.
- /// The target project file path. If not specified, the command searches the current directory for one.
- /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
- ///
- ///
- /// DotNetAddReference("./app/app.csproj", GetFiles("./src/*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
- public static void DotNetAddReference(this ICakeContext context, string project, IEnumerable projectReferences)
- {
- context.DotNetAddReference(project, projectReferences, null);
- }
-
- ///
- /// Adds project-to-project (P2P) references.
- ///
- /// The context.
- /// The target project file path. If not specified, the command searches the current directory for one.
- /// One or more project references to add. Glob patterns are supported on Unix/Linux-based systems.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetReferenceAddSettings
- /// {
- /// Framework = "net8.0"
- /// };
- ///
- /// DotNetAddReference("./app/app.csproj", GetFiles("./src/*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Add")]
- public static void DotNetAddReference(this ICakeContext context, string project, IEnumerable projectReferences, DotNetReferenceAddSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetReferenceAddSettings();
- }
-
- var adder = new DotNetReferenceAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- adder.Add(project, projectReferences, settings);
- }
-
- ///
- /// Removes project-to-project (P2P) references.
- ///
- /// The context.
- /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
- ///
- ///
- /// DotNetRemoveReference(GetFiles("./src/*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
- public static void DotNetRemoveReference(this ICakeContext context, IEnumerable projectReferences)
- {
- context.DotNetRemoveReference(projectReferences, null);
- }
-
- ///
- /// Removes project-to-project (P2P) references.
- ///
- /// The context.
- /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetReferenceRemoveSettings
- /// {
- /// Framework = "net8.0"
- /// };
- ///
- /// DotNetRemoveReference(GetFiles("./src/*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
- public static void DotNetRemoveReference(this ICakeContext context, IEnumerable projectReferences, DotNetReferenceRemoveSettings settings)
- {
- context.DotNetRemoveReference(null, projectReferences, settings);
- }
-
- ///
- /// Removes project-to-project (P2P) references.
- ///
- /// The context.
- /// Target project file. If not specified, the command searches the current directory for one.
- /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
- ///
- ///
- /// DotNetRemoveReference("./app/app.csproj", GetFiles("./src/*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
- public static void DotNetRemoveReference(this ICakeContext context, string project, IEnumerable projectReferences)
- {
- context.DotNetRemoveReference(project, projectReferences, null);
- }
-
- ///
- /// Removes project-to-project (P2P) references.
- ///
- /// The context.
- /// Target project file. If not specified, the command searches the current directory for one.
- /// Project-to-project (P2P) references to remove. You can specify one or multiple projects. Glob patterns are supported on Unix/Linux based terminals.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetReferenceRemoveSettings
- /// {
- /// Framework = "net8.0"
- /// };
- ///
- /// DotNetRemoveReference("./app/app.csproj", GetFiles("./src/*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.Remove")]
- public static void DotNetRemoveReference(this ICakeContext context, string project, IEnumerable projectReferences, DotNetReferenceRemoveSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetReferenceRemoveSettings();
- }
-
- var remover = new DotNetReferenceRemover(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- remover.Remove(project, projectReferences, settings);
- }
-
- ///
- /// Lists project-to-project references.
- ///
- /// The context.
- /// The list of project-to-project references.
- ///
- ///
- /// var references = DotNetListReference();
- ///
- /// foreach (var reference in references)
- /// {
- /// Information(reference);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.List")]
- public static IEnumerable DotNetListReference(this ICakeContext context)
- {
- return context.DotNetListReference(null);
- }
-
- ///
- /// Lists project-to-project references.
- ///
- /// The context.
- /// The project file to operate on. If a file is not specified, the command will search the current directory for one.
- /// The list of project-to-project references.
- ///
- ///
- /// var references = DotNetListReference("./app/app.csproj");
- ///
- /// foreach (var reference in references)
- /// {
- /// Information(reference);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.List")]
- public static IEnumerable DotNetListReference(this ICakeContext context, string project)
- {
- return context.DotNetListReference(project, null);
- }
-
- ///
- /// Lists project-to-project references.
- ///
- /// The context.
- /// The project file to operate on. If a file is not specified, the command will search the current directory for one.
- /// The settings.
- /// The list of project-to-project references.
- ///
- ///
- /// var settings = new DotNetReferenceListSettings
- /// {
- /// Verbosity = DotNetVerbosity.Diagnostic
- /// };
- ///
- /// var references = DotNetListReference("./app/app.csproj", settings);
- ///
- /// foreach (var reference in references)
- /// {
- /// Information(reference);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Reference")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Reference.List")]
- public static IEnumerable DotNetListReference(this ICakeContext context, string project, DotNetReferenceListSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetReferenceListSettings();
- }
-
- var lister = new DotNetReferenceLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return lister.List(project, settings);
- }
-
- ///
- /// List packages on available from source using specified settings.
- ///
- /// The context.
- /// The search term.
- /// The settings.
- /// List of packages with their version.
- ///
- ///
- /// var packageList = DotNetPackageSearch("Cake", new DotNetPackageSearchSettings {
- /// AllVersions = false,
- /// Prerelease = false
- /// });
- /// foreach(var package in packageList)
- /// {
- /// Information("Found package {0}, version {1}", package.Name, package.Version);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Search")]
- public static IEnumerable DotNetSearchPackage(this ICakeContext context, string searchTerm, DotNetPackageSearchSettings settings)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
- var runner = new DotNetPackageSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return runner.Search(searchTerm, settings);
- }
-
- ///
- /// List packages on available from source using specified settings.
- ///
- /// The context.
- /// The package Id.
- /// List of packages with their version.
- ///
- ///
- /// var packageList = DotNetPackageSearch("Cake", new DotNetPackageSearchSettings {
- /// AllVersions = false,
- /// Prerelease = false
- /// });
- /// foreach(var package in packageList)
- /// {
- /// Information("Found package {0}, version {1}", package.Name, package.Version);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Search")]
- public static IEnumerable DotNetSearchPackage(this ICakeContext context, string searchTerm)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
- var runner = new DotNetPackageSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return runner.Search(searchTerm, new DotNetPackageSearchSettings());
- }
-
- ///
- /// List packages on available from source using specified settings.
- ///
- /// The context.
- /// The settings.
- /// List of packages with their version.
- ///
- ///
- /// var packageList = DotNetPackageSearch("Cake", new DotNetPackageSearchSettings {
- /// AllVersions = false,
- /// Prerelease = false
- /// });
- /// foreach(var package in packageList)
- /// {
- /// Information("Found package {0}, version {1}", package.Name, package.Version);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.Search")]
- public static IEnumerable DotNetSearchPackage(this ICakeContext context, DotNetPackageSearchSettings settings)
- {
- if (context == null)
- {
- throw new ArgumentNullException(nameof(context));
- }
- var runner = new DotNetPackageSearcher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return runner.Search(null, settings);
- }
-
- ///
- /// Lists the package references for a project or solution.
- ///
- /// The context.
- /// The the package references.
- ///
- ///
- /// DotNetPackageList output = DotNetListPackage();
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.List")]
- public static DotNetPackageList DotNetListPackage(this ICakeContext context)
- {
- return context.DotNetListPackage(null);
- }
-
- ///
- /// Lists the package references for a project or solution.
- ///
- /// The context.
- /// The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown.
- /// The the package references.
- ///
- ///
- /// DotNetPackageList output = DotNetListPackage("./src/MyProject/MyProject.csproj");
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.List")]
- public static DotNetPackageList DotNetListPackage(this ICakeContext context, string project)
- {
- return context.DotNetListPackage(project, null);
- }
-
- ///
- /// Lists the package references for a project or solution.
- ///
- /// The context.
- /// The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown.
- /// The settings.
- /// The the package references.
- ///
- ///
- /// var settings = new DotNetPackageListSettings
- /// {
- /// Outdated = true
- /// };
- ///
- /// DotNetPackageList output = DotNetListPackage("./src/MyProject/MyProject.csproj", settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Package")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Package.List")]
- public static DotNetPackageList DotNetListPackage(this ICakeContext context, string project, DotNetPackageListSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetPackageListSettings();
- }
-
- var lister = new DotNetPackageLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return lister.List(project, settings);
- }
-
- ///
- /// Lists all projects in a solution file.
- ///
- /// The context.
- /// The list of projects.
- ///
- ///
- /// var projects = DotNetSlnList();
- ///
- /// foreach (var project in projects)
- /// {
- /// Information(project);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.List")]
- public static IEnumerable DotNetSlnList(this ICakeContext context)
- {
- return context.DotNetSlnList(null);
- }
-
- ///
- /// Lists all projects in a solution file.
- ///
- /// The context.
- /// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails.
- /// The list of projects.
- ///
- ///
- /// var projects = DotNetSlnList("./app/app.sln");
- ///
- /// foreach (var project in projects)
- /// {
- /// Information(project);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.List")]
- public static IEnumerable DotNetSlnList(this ICakeContext context, FilePath solution)
- {
- return context.DotNetSlnList(solution, null);
- }
-
- ///
- /// Lists all projects in a solution file.
- ///
- /// The context.
- /// The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails.
- /// The settings.
- /// The list of projects.
- ///
- ///
- /// var settings = new DotNetSlnListSettings
- /// {
- /// Verbosity = DotNetVerbosity.Diagnostic
- /// };
- ///
- /// var projects = DotNetSlnList("./app/app.sln");
- ///
- /// foreach (var project in projects)
- /// {
- /// Information(project);
- /// }
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.List")]
- public static IEnumerable DotNetSlnList(this ICakeContext context, FilePath solution, DotNetSlnListSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetSlnListSettings();
- }
-
- var lister = new DotNetSlnLister(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- return lister.List(solution, settings);
- }
-
- ///
- /// Adds one or more projects to the solution file.
- ///
- /// The context.
- /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
- ///
- ///
- /// DotNetSlnAdd(GetFiles("./*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
- public static void DotNetSlnAdd(this ICakeContext context, IEnumerable projectPath)
- {
- context.DotNetSlnAdd(null, projectPath);
- }
-
- ///
- /// Adds one or more projects to the solution file.
- ///
- /// The context.
- /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
- /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
- ///
- ///
- /// DotNetSlnAdd("app.sln", GetFiles("./*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
- public static void DotNetSlnAdd(this ICakeContext context, FilePath solution, IEnumerable projectPath)
- {
- context.DotNetSlnAdd(solution, projectPath, null);
- }
-
- ///
- /// Adds one or more projects to the solution file.
- ///
- /// The context.
- /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetSlnAddSettings
- /// {
- /// SolutionFolder = "libs/math"
- /// };
- ///
- /// DotNetSlnAdd(GetFiles("./*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
- public static void DotNetSlnAdd(this ICakeContext context, IEnumerable projectPath, DotNetSlnAddSettings settings)
- {
- context.DotNetSlnAdd(null, projectPath, settings);
- }
-
- ///
- /// Adds one or more projects to the solution file.
- ///
- /// The context.
- /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
- /// The path to the project or projects to add to the solution. Glob patterns are supported on Unix/Linux-based systems.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetSlnAddSettings
- /// {
- /// SolutionFolder = "libs/math"
- /// };
- ///
- /// DotNetSlnAdd("app.sln", GetFiles("./*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Add")]
- public static void DotNetSlnAdd(this ICakeContext context, FilePath solution, IEnumerable projectPath, DotNetSlnAddSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetSlnAddSettings();
- }
-
- var adder = new DotNetSlnAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- adder.Add(solution, projectPath, settings);
- }
-
- ///
- /// Removes a project or multiple projects from the solution file.
- ///
- /// The context.
- /// The path to the project or projects to remove from the solution.
- ///
- ///
- /// DotNetSlnRemove(GetFiles("./*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Remove")]
- public static void DotNetSlnRemove(this ICakeContext context, IEnumerable projectPath)
- {
- context.DotNetSlnRemove(null, projectPath);
- }
-
- ///
- /// Removes a project or multiple projects from the solution file.
- ///
- /// The context.
- /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
- /// The path to the project or projects to remove from the solution.
- ///
- ///
- /// DotNetSlnRemove("app.sln", GetFiles("./*.csproj"));
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Remove")]
- public static void DotNetSlnRemove(this ICakeContext context, FilePath solution, IEnumerable projectPath)
- {
- context.DotNetSlnRemove(solution, projectPath, null);
- }
-
- ///
- /// Removes a project or multiple projects from the solution file.
- ///
- /// The context.
- /// The solution file to use. If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.
- /// The path to the project or projects to remove from the solution.
- /// The settings.
- ///
- ///
- /// var settings = new DotNetSlnRemoveSettings
- /// {
- /// Verbosity = DotNetVerbosity.Diagnostic
- /// };
- ///
- /// DotNetSlnRemove("app.sln", GetFiles("./*.csproj"), settings);
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory("Sln")]
- [CakeNamespaceImport("Cake.Common.Tools.DotNet.Sln.Remove")]
- public static void DotNetSlnRemove(this ICakeContext context, FilePath solution, IEnumerable projectPath, DotNetSlnRemoveSettings settings)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- if (settings is null)
- {
- settings = new DotNetSlnRemoveSettings();
- }
-
- var remover = new DotNetSlnRemover(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
- remover.Remove(solution, projectPath, settings);
- }
}
}