AutomationIoC 1.1.0-alpha2
See the version list below for details.
dotnet add package AutomationIoC --version 1.1.0-alpha2
NuGet\Install-Package AutomationIoC -Version 1.1.0-alpha2
<PackageReference Include="AutomationIoC" Version="1.1.0-alpha2" />
paket add AutomationIoC --version 1.1.0-alpha2
#r "nuget: AutomationIoC, 1.1.0-alpha2"
// Install AutomationIoC as a Cake Addin #addin nuget:?package=AutomationIoC&version=1.1.0-alpha2&prerelease // Install AutomationIoC as a Cake Tool #tool nuget:?package=AutomationIoC&version=1.1.0-alpha2&prerelease
AutomationIoC
Dependency Injection Framework for C# PowerShell Cmdlets
Requirements
Getting Started
Installation
dotnet add package AutomationIoC
Development
See Sample Project for a full sample solution
Add the following to your .csproj file
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Add a PowerShell Startup Command
[Cmdlet(VerbsLifecycle.Install, "Dependencies")]
public class Startup : AutomationStartup
{
// Add any configuration sources or data needed
public override void Configure(IConfigurationBuilder configurationBuilder)
{
var appSettings = new Dictionary<string, string>()
{
["TestOptionsConfig:TestProperty"] = "This is an example",
};
configurationBuilder.AddInMemoryCollection(appSettings);
}
// Configure services/lifetimes
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<TestOptions>(Configuration.GetSection("TestOptionsConfig"));
services.AddSingleton<TestService>();
// other services, client, etc.
}
}
Add a PowerShell Command with Dependencies Injected
Synchronous process example
[Cmdlet(VerbsLifecycle.Submit, "TestData")]
public class SubmitTestData : IoCShell
{
// Supports non-public properties
[AutomationDependency]
protected TestDependencyOne TestDependencyOne { get; set; }
// Supports non-public fields
[AutomationDependency]
private readonly TestDependencyTwo testDependencyTwo;
[AutomationDependency]
private readonly ILogger<RequestCard> logger;
protected override void ExecuteCmdlet()
{
string id = Guid.NewGuid();
TestDependencyOne.PushTestId(id);
TestData testData = testDependencyTwo.GetTestData(id);
logger.LogInformation("Auto Generated Data: {Id} - {Name}", id, testData.Name);
}
}
Asynchronous process example
[Cmdlet(VerbsLifecycle.Submit, "TestDataAsync")]
public class SubmitTestDataAsync : IoCShellAsync
{
// Supports non-public properties
[AutomationDependency]
protected TestDependencyOne TestDependencyOne { get; set; }
// Supports non-public fields
[AutomationDependency]
private readonly TestDependencyTwo testDependencyTwo;
[AutomationDependency]
private readonly ILogger<RequestCard> logger;
protected override async Task ExecuteCmdletAsync()
{
string id = Guid.NewGuid();
await TestDependencyOne.PushTestIdAsync(id);
TestData testData = await testDependencyTwo.GetTestDataAsync(id);
logger.LogInformation("Auto Generated Data: {Id} - {Name}", id, testData.Name);
}
}
Execution
In PowerShell terminal run the following:
Import-Module <path-to-your-dll>/<your-assembly>.dll -V
You should see your custom commands listed in the verbose output (signaled by -v
)
See Project - launch.json for a sample on launching your module through VS Code
Load the dependency injection (this will be the command you created for startup). The following example is based on command name from above startup example
Load-Dependencies
Now you are ready to run your own custom commands!
Testing
NOTE: If using a constructor to inject dependencies for testing purposes, be sure to add an empty default constructor as well
Test Example Coming Soon
Other Resources
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 was computed. 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. |
-
net6.0
- AutomationIoC.SDK (>= 1.1.0-alpha2)
- AutomationIoC.Tools (>= 1.1.0-alpha2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on AutomationIoC:
Package | Downloads |
---|---|
AutomationIoC.Consoles
Dependency Injection Framework for C# Console Applications |
|
AutomationIoC.PSCmdlets
PSCmdlet SDK utilities for AutomationIoC framework development |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
2.1.0-alpha2 | 678 | 8/12/2023 | |
2.1.0-alpha1 | 692 | 6/16/2023 | |
2.0.0-preview1 | 682 | 6/16/2023 | |
2.0.0-alpha1 | 692 | 6/10/2023 | |
1.3.0 | 950 | 11/24/2022 | |
1.2.0 | 964 | 11/11/2022 | |
1.1.0 | 1,131 | 4/4/2022 | |
1.1.0-beta1 | 728 | 3/31/2022 | |
1.1.0-alpha2 | 714 | 3/26/2022 | |
1.1.0-alpha1 | 712 | 3/26/2022 | |
1.0.0 | 1,104 | 3/8/2022 | |
1.0.0-preview1 | 731 | 3/6/2022 | |
1.0.0-beta1 | 647 | 2/27/2022 | |
1.0.0-alpha2 | 712 | 2/27/2022 |