Smi.NetCore.Extensions.Hosting
1.0.0
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
<PackageReference Include="Smi.NetCore.Extensions.Hosting" Version="1.0.0" />
paket add Smi.NetCore.Extensions.Hosting --version 1.0.0
#r "nuget: Smi.NetCore.Extensions.Hosting, 1.0.0"
// 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
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
- Add a reference to Smi.NetCore.Extensions.Hosting in your dotnet core console app
- 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 | Versions 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. |
-
.NETCoreApp 2.2
- Microsoft.Extensions.Configuration (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.CommandLine (>= 2.2.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 2.2.0)
- Microsoft.Extensions.Hosting (>= 2.2.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 2.2.0)
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.