Jig.Shell
0.3.0
dotnet add package Jig.Shell --version 0.3.0
NuGet\Install-Package Jig.Shell -Version 0.3.0
<PackageReference Include="Jig.Shell" Version="0.3.0" />
<PackageVersion Include="Jig.Shell" Version="0.3.0" />
<PackageReference Include="Jig.Shell" />
paket add Jig.Shell --version 0.3.0
#r "nuget: Jig.Shell, 0.3.0"
#:package Jig.Shell@0.3.0
#addin nuget:?package=Jig.Shell&version=0.3.0
#tool nuget:?package=Jig.Shell&version=0.3.0
Jig Shell
Overview
Provides a utility to directly invoke shell commands using and bash-like syntax, and ITarget extensions
to add these as invocations.
Usage
Configuring
Call .AddShell() when constructing the build to make shell execution available to the build.
Basic Usage
Call .Executes() on a target with the command string:
ITarget Target => field ??= new Target()
.Executes(
$"ENV_VAR1=val1 dotnet build Solution.sln --verbosity {Verbosity.Value}",
ShellLoggingOptions.StandardError
);
This will add an execution to the target to invoke the specified process from the application working directory
using the environment variables and arguments supplied in the string. The command executed, standard output, and standard error
will be logged to the available ITargetLogger depending on the ShellLoggingOptions provided. By default all logging
options are enabled.
Shell Execution
Commands can be executed in shells instead of process invocation:
ExectutesBash: Runs the command using bashExectutesZsh: Runs the command using zshExectutesDash: Runs the command using dash/shExectutesAsh: Runs the command using BusyBox ashExectutesPowerShell: Runs the command using powershell/pwshExectutesNativeShell: Runs the command using the default shell depending on the OS and environment
DotNet Tool Execution
Call ExecutesDotNetTool() on a target specifying the dotnet tool to call and arguments to supply to it:
ITarget Target => field ??= new Target()
.ExecutesDotNetTool($"jetbrains.resharper.globaltools cleanupcode Solution.sln"));
// > dotnet tool exec -y --allow-roll-forward --ignore-failed-sources jetbrains.resharper.globaltools -- cleanupcode Solution.sln"
This command definition will be transformed into a dotnet tool exec command running the tool with the targets
supplied, running the tool with the specified arguments.
Manual Invocation
A Shell singleton instance is injected into the build on configuration. This can be resolved using normal execution
and used for more complex calls:
ITarget Target => field ??= new Target()
.Executes((Shell shell) =>
{
var output = await shell
.Command($"ENV_VAR1=val1 dotnet build Solution.sln --verbosity {Verbosity.Value}")
.ExecuteAndCaptureOutputAsync(buildContext.StoppingToken)
.ToArrayAsync()
// Process output
});
Argument Redaction
Arguments can be redacted in logs by specifying :redacted in the argument format.
ITarget Target => field ??= new Target()
.Executes($"dotnet nuget push --api-key {ApiKey:redacted}");
// > dotnet nuget push --api_key [REDACTED]
Sensitive BuildOptions are always redacted.
BuildOption<string> ApiKey { get; } = new("--api-key", sensitive: true)
ITarget Target => field ??= new Target()
.Executes($"dotnet nuget push --api-key {ApiKey}");
// > dotnet nuget push --api_key [REDACTED]
Acknowledgements
Made trivial by:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- CliWrap (>= 3.10.0)
- Jig (>= 0.3.0)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Jig.Shell:
| Package | Downloads |
|---|---|
|
Jig.Apt
Jig extension adding apt package utilities for targets |
|
|
Jig.DesktopNotifications
Jig extension adding desktop build notification hooks. |
GitHub repositories
This package is not used by any popular GitHub repositories.