Summary
Executes a generic tool/process based on arguments and settings.
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
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