AutomationIoC.Consoles
2.1.0-alpha2
Suggested Alternatives
This is a prerelease version of AutomationIoC.Consoles.
dotnet add package AutomationIoC.Consoles --version 2.1.0-alpha2
NuGet\Install-Package AutomationIoC.Consoles -Version 2.1.0-alpha2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutomationIoC.Consoles" Version="2.1.0-alpha2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutomationIoC.Consoles --version 2.1.0-alpha2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AutomationIoC.Consoles, 2.1.0-alpha2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AutomationIoC.Consoles as a Cake Addin #addin nuget:?package=AutomationIoC.Consoles&version=2.1.0-alpha2&prerelease // Install AutomationIoC.Consoles as a Cake Tool #tool nuget:?package=AutomationIoC.Consoles&version=2.1.0-alpha2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AutomationIoC.Consoles
Dependency Injection Framework for C# Console Applications
Requirements
Getting Started
Installation
dotnet add package AutomationIoC.Consoles
Development
See Sample Project for a full sample solution
Create AutomationIoC Consoles Command to run
public class TestCommand : StandardCommand
{
public override void ConfigureCommand(IServiceBinderFactory serviceBinderFactory, Command command)
{
var greetingOption = new Option<string>(
name: "--greeting",
description: "New greeting to display.");
command.AddOption(greetingOption);
command.SetHandler(UpdateGreeting,
greetingOption,
serviceBinderFactory.Create<ITestService>(),
serviceBinderFactory.Create<IConfiguration>());
}
public override Action<IConfigurationBuilder> ConfigurationBuilder => (configurationBuilder) =>
{
var appSettings = new Dictionary<string, string>()
{
["CurrentGreetingMessage"] = "Current Greeting: {0}",
["NewGreetingMessage"] = "New Greeting: {0}"
};
};
public override Action<IServiceCollection> Services => (serviceCollection) =>
{
serviceCollection.AddScoped<ITestService, TestService>();
};
private void UpdateGreeting(
string newGreeting,
ITestService testService,
IConfiguration configuration)
{
string unformattedCurrentGreeting = configuration.GetValue<string>("CurrentGreetingMessage");
string unformattedNewGreeting = configuration.GetValue<string>("NewGreetingMessage");
string currentGreeting = testService.GetGreeting();
Console.WriteLine(unformattedCurrentGreeting, currentGreeting);
string updatedGreeting = testService.UpdateGreeting(newGreeting);
Console.WriteLine(unformattedNewGreeting, updatedGreeting);
}
}
Add AutomationIoC Consoles Builder in startup
class Program
{
static void Main(string[] args)
{
IAutomationIoConsoleBuilder builder =
AutomationIoConsole.CreateDefaultBuilder(args)
// Add command name/path here
.AddCommand<TestCommand>("greet");
IAutomationIoConsole console = builder.Build();
console.Run();
}
}
Run command
dotnet run -- greet --greeting "Hello World"
Other Resources
Related Packages
Package | Description |
---|---|
AutomationIoC | Framework Runtime for AutomationIoC Console Applications and PowerShell Cmdlets |
AutomationIoC.PSCmdlets | Dependency Injection Framework for C# PowerShell Cmdlets |
AutomationIoC.PSCmdlets.Tools | Tooling for running/testing C# PowerShell Cmdlets |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- AutomationIoC (>= 2.1.0-alpha2)
- System.CommandLine (>= 2.0.0-beta4.22272.1)
-
net7.0
- AutomationIoC (>= 2.1.0-alpha2)
- System.CommandLine (>= 2.0.0-beta4.22272.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
2.1.0-alpha2 | 152 | 8/12/2023 | |
2.1.0-alpha1 | 118 | 6/16/2023 | |
2.0.0-preview1 | 91 | 6/16/2023 | |
2.0.0-alpha1 | 90 | 6/10/2023 |