Cmpnnt.Pia.DependencyInjection 0.3.0

dotnet add package Cmpnnt.Pia.DependencyInjection --version 0.3.0                
NuGet\Install-Package Cmpnnt.Pia.DependencyInjection -Version 0.3.0                
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="Cmpnnt.Pia.DependencyInjection" Version="0.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cmpnnt.Pia.DependencyInjection --version 0.3.0                
#r "nuget: Cmpnnt.Pia.DependencyInjection, 0.3.0"                
#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 Cmpnnt.Pia.DependencyInjection as a Cake Addin
#addin nuget:?package=Cmpnnt.Pia.DependencyInjection&version=0.3.0

// Install Cmpnnt.Pia.DependencyInjection as a Cake Tool
#tool nuget:?package=Cmpnnt.Pia.DependencyInjection&version=0.3.0                

Cmpnnt.Pia.DependencyInjection

This is a dependency injection helper package for cmpnnt.pia.ctl.

Cmpnnt.Pia.Ctl is a .NET Native AOT wrapper around piactl, the Private Internet Access CLI for Windows and Linux. MacOS support will be added when GitHub makes free runners available.

PIA Sharp's main package, Cmpnnt.Pia.Ctl, has been tested against version 3.3.1 on Windows and Linux. It provides access to every piactl command available in those version on those systems. It might also work on other versions of piactl, provided they expose the same commands with the same parameters. However, this hasn't been tested and nothing is guaranteed.

Dependency Injection

There's a separate dependency injection library you can use if you require DI. Add a reference to Cmpnnt.Pia.DependencyInjection and include it in your DI container by adding a call to services.AddPiaCtl() under ConfigureServices.

Note: The dependency injection package registers PiaCtl as a singleton.

Here's a basic example. You can find the runnable code in the examples project.

using IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.AddPiaCtl();
        services.AddScoped<SomeClass>();
    })
    .ConfigureLogging(options =>
    {
        options.ClearProviders();
        options.AddConsole();
    })
    .Build();

Configuration

You can also pass a lambda function to AddPiaCtl to configure the path to your system's piactl application, if it differs from the default. On Windows, the default location is C:\Program Files\Private Internet Access\piactl.exe.

using IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.AddPiaCtl(options =>
        {
            options.PiaPath = @"C:\path\to\piactl.exe";
        });
        services.AddScoped<SomeClass>();
    })
    .ConfigureLogging(options =>
    {
        options.ClearProviders();
        options.AddConsole();
    })
    .Build();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.

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
0.3.0 108 8/28/2024