Summary
Executes a generic tool/process based on arguments and settings.
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
Parameters
Return Value
Type |
Description |
int |
The exit code. |