Automatically build and deploy .NET core 3 console application as a Windows service

Tai Bo
6 min readJul 25, 2020
Image by Natalia Ovcharenko from Pixabay

In this post, I want to share an example of using Azure Devops to automatically build and deploy a .NET console application as a windows service to run on a Windows VM.

Enable .NET core 3 app to run as a windows service

For this example, I have scaffolded a simple .NET core console application using Visual Studio. It is a very rudimentary app which logs out a message every minute until stop. You can generate a similar project using Worker Service Template as a starting point. You can checkout the codes for this project on my Github repo.

At the high level, to enable a .NET core app to run as a windows service, you need the following:

public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services)…

--

--

Tai Bo

Backend developer in .NET core. I enjoy the outdoor, hanging out with good friends, reading and personal development.