Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.

icenorge/DotNetCore.WindowsServices

Repository files navigation

DEPRECATION NOTICE

From .NET Core 3, Windows Services are supported by the framework. Use https://www.nuget.org/packages/Microsoft.Extensions.Hosting.WindowsServices .

Build status

Build server Platform Status
AppVeyor Windows Build status
Travis Linux Build Status

NuGet NuGet

DotNetCore.WindowsServices

The bare minimum for running a .NET Core 2 console app as a Windows Service. Currently, there's a NuGet for running ASP.NET Core apps as a Windows Service, but there's only a sample on how to do non web .NET Core apps as Windows Services. This NuGet extracts the code from that sample so it's more easily available.

Install

> dotnet add package DotNetCore.WindowsServices

Usage

static async Task Main(string[] args)
{
    var host = new HostBuilder();
    host.ConfigureServices(c => c.AddSingleton<IHostedService, BackgroundWorker>());
    await host.RunAsServiceAsync();
}

NB.

This will of course only work on Windows. Running it on another platform throws PlatformNotSupportedExceptions.

About

The bare minimum to get a .NET Core 2 application running as a Windows Service

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •