Curiosus.Hosting
3.0.0
dotnet add package Curiosus.Hosting --version 3.0.0
NuGet\Install-Package Curiosus.Hosting -Version 3.0.0
<PackageReference Include="Curiosus.Hosting" Version="3.0.0" />
<PackageVersion Include="Curiosus.Hosting" Version="3.0.0" />
<PackageReference Include="Curiosus.Hosting" />
paket add Curiosus.Hosting --version 3.0.0
#r "nuget: Curiosus.Hosting, 3.0.0"
#:package Curiosus.Hosting@3.0.0
#addin nuget:?package=Curiosus.Hosting&version=3.0.0
#tool nuget:?package=Curiosus.Hosting&version=3.0.0
Curiosus.Hosting
App bootstrappers for console tools and background services. They parse CLI arguments, load and validate a YAML config,
set up NLog and the default culture, run registered IAppInitializers and then start the app.
Installation
dotnet add package Curiosus.Hosting
Usage
Inherit a configuration from CuriosusAppConfiguration and a bootstrapper from CuriosusServiceAppBootstrapper
(generic host with hosted services) or CuriosusToolAppBootstrapper (a DI container plus a one-shot ExecuteAsync).
public class AppConfiguration : CuriosusAppConfiguration
{
public AppConfiguration()
{
AppName = "Sample Worker";
}
}
public class AppBootstrapper : CuriosusServiceAppBootstrapper<CuriosusCLIArguments, AppConfiguration>
{
public AppBootstrapper()
{
ConfigureServices((context, services, configuration) =>
{
services.AddHostedService<SampleWorker>();
});
}
}
// Program.cs
return await new AppBootstrapper().RunAsync(args);
The config is read from config.yml in the directory passed with -c|--config (the current working directory
by default). It is overridden by config.secret.yml, config.{ASPNETCORE_ENVIRONMENT}.yml, environment variables
and CLI arguments.
AppName: Sample Worker
Culture:
DefaultCulture: en-US
Log:
LogConfigurationPath: ./NLog.config
LogOutputDirectory: ./logs
RunAsync returns an exit code from CuriosusExitCodes (e.g. IncorrectConfiguration when validation fails).
The configuration, the CLI arguments and a non-generic ILogger are registered in DI.
Other helpers:
CuriosusWatchdog— baseBackgroundServicethat callsProcessAsyncperiodically and survives exceptions.AddThreadPoolTuning(ThreadPoolOptions)— sets minimum thread pool size, logs its state and can auto-tune it.AddTempDirCleaner(TempFileOptions)— hosted service that deletes stale temp files.IConfigurationWithMailLogger— implement it in your config to pass SMTP settings (LoggerMail) to the mail target variables of yourNLog.config.
See also
- Curiosus.Hosting.Web — bootstrapper for ASP.NET Core apps
- Curiosus.Configuration.YML — YAML configuration provider
- Curiosus.Tools —
IAppInitializerand other basic helpers - Curiosus.Utils — all packages
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Curiosus.Configuration (>= 2.0.0)
- Curiosus.Configuration.YML (>= 2.1.0)
- Curiosus.Tools (>= 2.1.0)
- EntryPoint (>= 1.3.0)
- MailKit (>= 4.18.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Hosting (>= 10.0.3)
- Microsoft.Extensions.Localization (>= 10.0.3)
- Microsoft.Extensions.Localization.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Logging (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- NLog.Extensions.Logging (>= 6.0.0)
- NLog.MailKit (>= 6.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net9.0
- Curiosus.Configuration (>= 2.0.0)
- Curiosus.Configuration.YML (>= 2.1.0)
- Curiosus.Tools (>= 2.1.0)
- EntryPoint (>= 1.3.0)
- MailKit (>= 4.18.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.13)
- Microsoft.Extensions.Hosting (>= 9.0.13)
- Microsoft.Extensions.Localization (>= 9.0.13)
- Microsoft.Extensions.Localization.Abstractions (>= 9.0.13)
- Microsoft.Extensions.Logging (>= 9.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.13)
- NLog.Extensions.Logging (>= 6.0.0)
- NLog.MailKit (>= 6.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Curiosus.Hosting:
| Package | Downloads |
|---|---|
|
Curiosus.Hosting.Web
Hosting tools for Web applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.