CommandAliases.

Command(ICakeContext, CommandSettings, string, string, ProcessArgumentBuilder) 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 int Command(this ICakeContext context, CommandSettings settings, out string standardOutput, out string standardError, ProcessArgumentBuilder arguments = null)

Examples

 // Reusable tools settings i.e. created in setup.
 var settings = new CommandSettings {
         ToolName = ".NET CLI",
         ToolExecutableNames =  new []{ "dotnet", "dotnet.exe" },
      }.WithExpectedExitCode(1);

 // Example with ProcessArgumentBuilder
 var exitCode = Command(
     settings,
     out var standardOutput,
     out var standardError,
     new ProcessArgumentBuilder()
         .Append("tool")
 );

 Verbose("Exit code: {0}", exitCode);
 Information("Output: {0}", standardOutput);
 Error("Error: {0}", standardError);


 // Example with implicit ProcessArgumentBuilder
 var implicitExitCode = Command(
     settings,
     out var implicitStandardOutput,
     out var implicitStandardError,
     "tool"
 );

 Verbose("Exit code: {0}", implicitExitCode);
 Information("Output: {0}", implicitStandardOutput);
 Error("Error: {0}", implicitStandardError);

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.
settings CommandSettings The settings.
standardOutput string The standard output.
standardError string The standard error.
arguments ProcessArgumentBuilder The optional arguments.

Return Value

Type Description
int The exit code.