AutomationIoC 1.3.1

.NET 6.0
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AutomationIoC --version 1.3.1
NuGet\Install-Package AutomationIoC -Version 1.3.1
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" Version="1.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutomationIoC --version 1.3.1
#r "nuget: AutomationIoC, 1.3.1"
#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 as a Cake Addin
#addin nuget:?package=AutomationIoC&version=1.3.1

// Install AutomationIoC as a Cake Tool
#tool nuget:?package=AutomationIoC&version=1.3.1

Nuget Version Nuget Downloads Continuous Integration


Dependency Injection Framework for C# PowerShell Cmdlets


Getting Started


dotnet add package AutomationIoC


See Sample Project for a full sample solution

Add the following to your .csproj file


Add a Startup class

public class Startup : IoCStartup
    // Add any configuration sources or data needed
    public override void Configure(IConfigurationBuilder configurationBuilder)
        // AutomationEnvironment class allows retrieving global PowerShell
        // variables during service configuration.
        var environment =

        var appSettings = new Dictionary<string, string>()
            ["TestOptionsConfig:TestProperty"] = "This is an example",
            ["AppEnvironment"] = environment


    // Configure services/lifetimes
    public override void ConfigureServices(IServiceCollection services)

        services.AddTransient<ITestDependencyOne, TestDependencyOne>();
        services.AddTransient<ITestDependencyTwo, TestDependencyTwo>();
        // ...
        // other services, client, etc.

Add a PowerShell Command with Dependencies Injected

Synchronous process example

[Cmdlet(VerbsLifecycle.Submit, "Data")]
public class SubmitData : IoCShell<Startup>
    [Parameter(Mandatory = true)]
    public string Id { get; set; }

    protected ITestDependencyOne TestDependencyOne { get; set; }

    protected ITestDependencyTwo testDependencyTwo { get; set; }

    private ILogger<RequestCard> logger { get; set; }

    protected override void ProcessRecord()


        TestData testData = testDependencyTwo.GetTestData(Id);

        logger.LogInformation("Auto Generated Data: {Id} - {Name}", Id, testData.Name);


Asynchronous process example

[Cmdlet(VerbsLifecycle.Submit, "DataAsync")]
public class SubmitDataAsync : IoCShellAsync<Startup>
    [Parameter(Mandatory = true)]
    public string Id { get; set; }

    protected ITestDependencyOne TestDependencyOne { get; set; }

    protected ITestDependencyTwo testDependencyTwo { get; set; }

    private ILogger<RequestCard> logger { get; set; }

    protected override async Task ProcessRecordAsync()
        await TestDependencyOne.PushTestIdAsync(Id);

        TestData testData = await testDependencyTwo.GetTestDataAsync(Id);

        logger.LogInformation("Auto Generated Data: {Id} - {Name}", Id, testData.Name);



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).

Now you are ready to run your own custom commands!

The following example is based on command name from above:

Submit-Data -id "ThisIsATestId"

See Project - launch.json for a sample on launching your module through VS Code


using AutomationIoC.Tools;
using FluentAssertions;
using Xunit;

public class RequestCardTests
    public void ShouldSubmitData()
        var testDependencyOneMock = new Mock<ITestDependencyOne>();
        var testDependencyTwoMock = new Mock<ITestDependencyTwo>();
        var testId = "ThisIsATestId";
        var expectedTestData = new TestData { Id = testId, Name = "ThisIsTestName" };

        testDependencyTwoMock.Setup(dependency =>

        using var submitDataCommand =
            AutomationSandbox.CreateContext<SubmitData, Startup>(services =>
                services.AddTransient(_ => testDependencyOneMock.Object);
                services.AddTransient(_ => testDependencyTwoMock.Object);

        submitDataCommand.AddParameter(command =>
            command.AddParameter("id", testId));

        var actualTestData = submitDataCommand.RunCommand<TestData>().First();


Other Resources

Product 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. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on AutomationIoC:

Package Downloads

Dependency Injection Framework for C# Console Applications


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 150 8/12/2023
2.1.0-alpha1 187 6/16/2023
2.0.0-preview1 164 6/16/2023
2.0.0-alpha1 176 6/10/2023
1.3.1 401 11/24/2022
1.3.0 406 11/24/2022
1.2.0 443 11/11/2022
1.1.0 611 4/4/2022
1.1.0-beta1 230 3/31/2022
1.1.0-alpha2 212 3/26/2022
1.1.0-alpha1 192 3/26/2022
1.0.0 630 3/8/2022
1.0.0-preview1 200 3/6/2022
1.0.0-beta1 189 2/27/2022
1.0.0-alpha2 226 2/27/2022