CommandAliases.

Command(ICakeContext, ICollection<string>, ProcessArgumentBuilder, int, Func<CommandSettings, CommandSettings>) Method

Summary

Executes a generic tool/process based on arguments and settings.
Namespace
Cake.Common.Tools.Command
Containing Type
CommandAliases

Syntax

[CakeMethodAlias]
[CakeAliasCategory("Command")]
public static void Command(this ICakeContext context, ICollection<string> toolExecutableNames, ProcessArgumentBuilder arguments = null, int expectedExitCode = 0, Func<CommandSettings, CommandSettings> settingsCustomization = null)

Examples

 // Example with ProcessArgumentBuilder
 #tool dotnet:?package=DPI&version=2022.8.21.54
 Command(
     new []{ "dpi", "dpi.exe"},
     new ProcessArgumentBuilder()
         .Append("nuget")
         .AppendQuoted(Context.Environment.WorkingDirectory.FullPath)
         .AppendSwitch("--output", " ", "TABLE")
         .Append("analyze")
 );


 // Example with implicit ProcessArgumentBuilder
 Command(
     new []{ "dotnet", "dotnet.exe"},
     "--version"
 );


 // Example specify expected exit code
 Command(
     new []{ "dotnet", "dotnet.exe"},
     expectedExitCode: -2147450751
 );


 // Example settings customization
 Command(
     new []{ "dotnet", "dotnet.exe"},
     settingsCustomization: settings => settings
                                             .WithToolName(".NET tool")
                                             .WithExpectedExitCode(1)
                                             .WithArgumentCustomization(args => args.Append("tool"))
 );

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.
CakeAliasCategoryAttribute An attribute used for documentation of alias methods/properties.

Parameters

Name Type Description
context ICakeContext The context.
toolExecutableNames ICollection<string> The tool executable names.
arguments ProcessArgumentBuilder The optional arguments.
expectedExitCode int The expected exit code (default 0).
settingsCustomization Func<CommandSettings, CommandSettings> The optional settings customization (default null).

Return Value

Type Description
void