Smi.NetCore.Extensions.Hosting 1.0.0

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

// Install Smi.NetCore.Extensions.Hosting as a Cake Tool
#tool nuget:?package=Smi.NetCore.Extensions.Hosting&version=1.0.0                

Build status

Smi.Microsoft.NetCore.Extensions

A collection of useful extensions for .NET Core applications

1. Smi.NetCore.Extensions.Hosting

Purpose

Whilst working with an ASP.NET Core app, we have the hosting infrastructure to leverage. IWebHostBuidler exposes this and the default project template creates a Program.cs that calls into Startup.cs to bootstrap the application. For non ASP.NET application, we have IHostBuilder and IHost to use.

By default, using the Microsoft.Extensions.Hosting.Abstractions and Microsoft.Extensions.Hosting packages creates a Program.cs that has more than once concern thrown in:

  • Create the Host
  • Read and Wire up configuration from various sources
  • Map custom services into the dependency injection container.

This project aims to provide infrastructure that lets one create a console hosted application similar to an ASP.NET application with cleanly separated Program and Startup such that:

  • Program.cs has the sole responsibility of creating the host and specifying the Startup class
  • Startup.cs has the responsibility of configuring the application processing pipeline and dependency injection.

How to use

  1. Add a reference to Smi.NetCore.Extensions.Hosting in your dotnet core console app
  2. Initialize your host like so:
public class Program
    {
        public static async Task Main(string[] args)
        {
            // NOTE: TimedHostedService is an IHostedService implementation
            // Startup is a class that implements the IStartup interface
            await DefaultConsoleHost
                .CreateBuilder<TimedHostedService>(   
                    args, 
                    "MYAPP_",
                    nameof(Sample.ConsoleApp))
                .UseStartup<Startup>(args)
                .RunConsoleAsync();
        }
    }

Your application can now run as a daemon/service/dockerised app.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Smi.NetCore.Extensions.Hosting:

Package Downloads
Smi.NetCore.Extensions.Hosting.Lifetime

Provides infrastructure to create a console hosted application that can be configured to stay up based on a specified trigger ocurring periodically.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 957 5/3/2019
1.3.0 687 4/30/2019
1.2.1 677 4/29/2019
1.0.0 755 4/28/2019