I have a self-hosted .NET Core Console Application.
The web shows examples for ASP.NET Core but i do not have a webserver. Just a simple c
Another way would be using HostBuilder from Microsoft.Extensions.Hosting package.
public static async Task Main(string[] args)
{
var builder = new HostBuilder()
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.SetBasePath(Directory.GetCurrentDirectory());
config.AddJsonFile("appsettings.json", true);
if (args != null) config.AddCommandLine(args);
})
.ConfigureServices((hostingContext, services) =>
{
services.AddHostedService();
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration);
logging.AddConsole();
});
await builder.RunConsoleAsync();
}