-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4398 from Marusyk/marusyk/dotnetalias-partial
Refactor DotNetAliases: Extract methods into a separate partial class
- Loading branch information
Showing
19 changed files
with
3,515 additions
and
3,128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// <para>Contains functionality related to <see href="https://github.com/dotnet/cli">.NET CLI</see>.</para> | ||
/// <para> | ||
/// 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 <see href="https://www.microsoft.com/net/core">page</see> for information | ||
/// on how to install. | ||
/// </para> | ||
/// </summary> | ||
public static partial class DotNetAliases | ||
{ | ||
/// <summary> | ||
/// Build all projects. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="project">The projects path.</param> | ||
/// <example> | ||
/// <code> | ||
/// DotNetBuild("./src/*"); | ||
/// </code> | ||
/// </example> | ||
[CakeMethodAlias] | ||
[CakeAliasCategory("Build")] | ||
[CakeNamespaceImport("Cake.Common.Tools.DotNet.Build")] | ||
public static void DotNetBuild(this ICakeContext context, string project) | ||
{ | ||
context.DotNetBuild(project, null); | ||
} | ||
|
||
/// <summary> | ||
/// Build all projects. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="project">The projects path.</param> | ||
/// <param name="settings">The settings.</param> | ||
/// <example> | ||
/// <code> | ||
/// var settings = new DotNetBuildSettings | ||
/// { | ||
/// Framework = "netcoreapp2.0", | ||
/// Configuration = "Debug", | ||
/// OutputDirectory = "./artifacts/" | ||
/// }; | ||
/// | ||
/// DotNetBuild("./src/*", settings); | ||
/// </code> | ||
/// </example> | ||
[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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// <para>Contains functionality related to <see href="https://github.com/dotnet/cli">.NET CLI</see>.</para> | ||
/// <para> | ||
/// 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 <see href="https://www.microsoft.com/net/core">page</see> for information | ||
/// on how to install. | ||
/// </para> | ||
/// </summary> | ||
public static partial class DotNetAliases | ||
{ | ||
/// <summary> | ||
/// Shuts down build servers that are started from dotnet. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <example> | ||
/// <code> | ||
/// DotNetBuildServerShutdown(); | ||
/// </code> | ||
/// </example> | ||
[CakeMethodAlias] | ||
[CakeAliasCategory("Build Server")] | ||
[CakeNamespaceImport("Cake.Common.Tools.DotNet.BuildServer")] | ||
public static void DotNetBuildServerShutdown(this ICakeContext context) | ||
{ | ||
context.DotNetBuildServerShutdown(null); | ||
} | ||
|
||
/// <summary> | ||
/// Shuts down build servers that are started from dotnet. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="settings">The settings.</param> | ||
/// <example> | ||
/// <code> | ||
/// var settings = new DotNetBuildServerShutdownSettings | ||
/// { | ||
/// MSBuild = true | ||
/// }; | ||
/// | ||
/// DotNetBuildServerShutdown(settings); | ||
/// </code> | ||
/// </example> | ||
[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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// <para>Contains functionality related to <see href="https://github.com/dotnet/cli">.NET CLI</see>.</para> | ||
/// <para> | ||
/// 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 <see href="https://www.microsoft.com/net/core">page</see> for information | ||
/// on how to install. | ||
/// </para> | ||
/// </summary> | ||
public static partial class DotNetAliases | ||
{ | ||
/// <summary> | ||
/// Cleans a project's output. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="project">The project's path.</param> | ||
/// <example> | ||
/// <code> | ||
/// DotNetClean("./src/project"); | ||
/// </code> | ||
/// </example> | ||
[CakeMethodAlias] | ||
[CakeAliasCategory("Clean")] | ||
[CakeNamespaceImport("Cake.Common.Tools.DotNet.Clean")] | ||
public static void DotNetClean(this ICakeContext context, string project) | ||
{ | ||
context.DotNetClean(project, null); | ||
} | ||
|
||
/// <summary> | ||
/// Cleans a project's output. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="project">The projects path.</param> | ||
/// <param name="settings">The settings.</param> | ||
/// <example> | ||
/// <code> | ||
/// var settings = new DotNetCleanSettings | ||
/// { | ||
/// Framework = "netcoreapp2.0", | ||
/// Configuration = "Debug", | ||
/// OutputDirectory = "./artifacts/" | ||
/// }; | ||
/// | ||
/// DotNetClean("./src/project", settings); | ||
/// </code> | ||
/// </example> | ||
[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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// <para>Contains functionality related to <see href="https://github.com/dotnet/cli">.NET CLI</see>.</para> | ||
/// <para> | ||
/// 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 <see href="https://www.microsoft.com/net/core">page</see> for information | ||
/// on how to install. | ||
/// </para> | ||
/// </summary> | ||
public static partial class DotNetAliases | ||
{ | ||
/// <summary> | ||
/// Execute an assembly. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="assemblyPath">The assembly path.</param> | ||
/// <example> | ||
/// <code> | ||
/// DotNetExecute("./bin/Debug/app.dll"); | ||
/// </code> | ||
/// </example> | ||
[CakeMethodAlias] | ||
[CakeAliasCategory("Execute")] | ||
[CakeNamespaceImport("Cake.Common.Tools.DotNet.Execute")] | ||
public static void DotNetExecute(this ICakeContext context, FilePath assemblyPath) | ||
{ | ||
context.DotNetExecute(assemblyPath, null); | ||
} | ||
|
||
/// <summary> | ||
/// Execute an assembly with arguments in the specific path. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="assemblyPath">The assembly path.</param> | ||
/// <param name="arguments">The arguments.</param> | ||
/// <example> | ||
/// <code> | ||
/// DotNetExecute("./bin/Debug/app.dll", "--arg"); | ||
/// </code> | ||
/// </example> | ||
[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); | ||
} | ||
|
||
/// <summary> | ||
/// Execute an assembly with arguments in the specific path with settings. | ||
/// </summary> | ||
/// <param name="context">The context.</param> | ||
/// <param name="assemblyPath">The assembly path.</param> | ||
/// <param name="arguments">The arguments.</param> | ||
/// <param name="settings">The settings.</param> | ||
/// <example> | ||
/// <code> | ||
/// var settings = new DotNetExecuteSettings | ||
/// { | ||
/// FrameworkVersion = "1.0.3" | ||
/// }; | ||
/// | ||
/// DotNetExecute("./bin/Debug/app.dll", "--arg", settings); | ||
/// </code> | ||
/// </example> | ||
[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); | ||
} | ||
} | ||
} |
Oops, something went wrong.