Need help with DotNetCore.WindowsService?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

547 Stars 135 Forks MIT License 101 Commits 24 Opened issues


Simple library that allows one to host dot net core application as windows services. Perfect solution to power micro-services architecture.

Services available


Need anything else?

Contributors list


Simple library that allows one to host dot net core application as windows services. Perfect solution to power micro-services architecture.

Important note

This library was created to enable one to host CONSOLE dot net core applications. If you want to host a WEBSITE as a service, you're better of following


Using NuGet:

Install-Package PeterKottas.DotNetCore.WindowsService

Quick start

Easiest way to start is using a brand new template. Just do:

dotnet new -i PeterKottas.DotNetCore.WindowsService.Templates::*
This will add one template at the moment.

Follow up with this

mkdir NameOfYourProject
cd NameOfYourProject
dotnet new [ mcrsvc-min | mcrsvc-std ]
This will create a sample project for you. Next chapter explains its features in more details especially points 6 onwards if you used the template.

Community, feel encouraged to add more templates if you find something missing/usefull. I'll be more than happy to add these. Just copy the project in and follow instructions in if you need more specific behvaiour.


  1. Create .NETCore console app.

  2. Create your first service, something like this: ```cs public class ExampleService : IMicroService { public void Start() { Console.WriteLine("I started"); }

    public void Stop()
        Console.WriteLine("I stopped");

    } ```

  3. You can also inherit MicroService base class and take advantage of built in timers: ```cs public class ExampleService : MicroService, IMicroService { public void Start() { this.StartBase(); Timers.Start("Poller", 1000, () => { Console.WriteLine("Polling at {0}\n", DateTime.Now.ToString("o")); }, (e) => { Console.WriteLine("Exception while polling: {0}\n", e.ToString()); }); Console.WriteLine("I started"); }

    public void Stop()
        Console.WriteLine("I stopped");

    } ```

  4. Api for services (and yeah, it's similar to Topshelf, thanks for inspiration, I just couldn't wait for you guys to implement this): ```cs ServiceRunner.Run(config => { var name = config.GetDefaultName(); config.Service(serviceConfig => { serviceConfig.ServiceFactory((extraArguments, microServiceController) => { return new ExampleService(); }); serviceConfig.OnStart((service, extraArguments) => { Console.WriteLine("Service {0} started", name); service.Start(); });

        serviceConfig.OnStop(service =>
            Console.WriteLine("Service {0} stopped", name);
    serviceConfig.OnInstall(service =>
        Console.WriteLine("Service {0} installed", name);
    serviceConfig.OnUnInstall(service =>
        Console.WriteLine("Service {0} uninstalled", name);
    serviceConfig.OnPause(service =>
        Console.WriteLine("Service {0} paused", name);
    serviceConfig.OnContinue(service =>
        Console.WriteLine("Service {0} continued", name);
    serviceConfig.OnShutdown(service =>
        Console.WriteLine("Service {0} shutdown", name);
    serviceConfig.OnError(e =>
        Console.WriteLine("Service {0} errored with exception : {1}", name, e.Message);


    }); ```

  5. Optionally set the name of the service like this:

    ServiceRunner.Run(config =>
  6. Run the service without arguments and it runs like console app.

  7. Run the service with action:install and it will install the service.

  8. Run the service with action:uninstall and it will uninstall the service.

  9. Run the service with action:start and it will start the service.

  10. Run the service with action:stop and it will stop the service.

  11. Run the service with action:pause and it will pause the service.

  12. Run the service with action:continue and it will continue the service.

  13. Run the service with username:YOUR_USERNAME, password:YOUR_PASSWORD and action:install which installs it for the given account.

  14. Run the service with built-in-account:(NetworkService|LocalService|LocalSystem) and action:install which installs it for the given built in account. Defaults to LocalSystem.

  15. Run the service with description:YOUR_DESCRIPTION and it setup description for the service.

  16. Run the service with display-name:YOURDISPLAYNAME and it setup Display name for the service.

  17. Run the service with name:YOUR_NAME and it setup name for the service.

  18. Run the service with start-immediately:(true|false) to start service immediately after install. Defaults to true.

  19. You can find the complete example in PeterKottas.DotNetCore.Example project.

  20. Install the service using powershell:

    dotnet.exe $serviceDllPath action:install

Created and sponsored by

  • GuestBell - Customer centric online POS for Hotels and short terms stays.


  1. Fork it!
  2. Create your feature branch:
    git checkout -b my-new-feature
  3. Commit your changes:
    git commit -am 'Add some feature'
  4. Push to the branch:
    git push origin my-new-feature
  5. Submit a pull request :D




Huge thanks goes to @dasMulli the guy behind a useful lib which is one of the dependecies for this library.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.