How To Deploy .NET Core Windows Service

A quick 5 minute tutorial on how to deploy a .NET Core service on Windows Server/PC.

Photo by Florian Olivo on Unsplash

Configure your .NET Core project

When trying to deploy on a Windows Service, make sure you already configure your Program.cs accordingly. On the Program.cs add this config:

Image by Author

Configure your Windows Server

Downloading the required packages

Install the required packages before configuration.

Downloading the dotnet SDK

Deployments only need runtime, but if you want to have a more flexible environment that allows you to build and publish dll files rather than only running it you would want to install the latest dotnet SDK, here.

Install the Azure Artifacts Credential Provider

If you use private NuGet packages you might want to install Azure Artifacts Credentials you can find the latest release here and download the .zip package.

Image by Author

After downloading the zip archive, copy the plugins folder to %USERPROFILE%/.nuget.

Image by Author

Set your environment variables, open User Variable, and create a new entry.

Image by Author

Set the variable name to NUGET_PLUGIN_PATHS and because in this case, we are going to be using the azure credential provider, so set the value to

Image by Author

Then finish the setup by clicking OK on the Environment Variables dialog. Install the Azure Artifacts Credential Provider, full instructions can be seen here.

Publish your .NET Core application

Pull the project using Git

Get into the directory where you want to put the application.

Image by Author

Get inside the newly formed folder and run the dotnet publish command. Do dotnet publish -r win-x64 -c Release to make a windows installer on publishing.

Image by Author

If an authorization prompt to pops up, login using the Microsoft account and enter the code shown in the window.

Otherwise, it should show a successful build like so:

Image by Author

In this case, let’s assume D:\Projects\api.test\bin\Release\netcoreapp3.1\publish\zoom-service.exe is the physical path.

Run your .NET Core Service

Create the Service

First, create a Windows Service using the sc create command and enter the service name, in this case, would be ZoomService, and add the physical path to the BinPath.

An example command would be: sc create ZoomService BinPath=D:\Projects\api.test\bin\Release\netcoreapp3.1\publish\zoom-service.exe

Image by Author

Start the Service

After creating the Windows Service start it by using the sc start command. An example command would be: sc start ZoomService.

Image by Author

Make the Service auto initialize on Startup

Go to the Task Manager, and open the services tab, and right-click on your newly created service

Image by Author

Then click the Open Services option.

Image by Author

Right-click on the newly created service and choose Properties.

Image by Author

Change the Startup type from Manual to Automatic.
Finally, click Apply and then click OK.


In this tutorial, you have learned how to serve a .NET Core application Windows service. To recap what we have done:

  • We have configured our .NET Core project as a Windows service.
  • We installed the required dotnet SDKs and the corresponding Azure authentication providers.
  • We have deployed the project as a Windows service.

You now have an open playbook to use when you want to deploy dotnet applications as a service. Hope this tutorial was of help and have a nice day!




A World-Class center for innovative ICT enabling the vigorous pursuit of outstanding BINA NUSANTARA services.

Recommended from Medium

Announcing the APIS Partnership with DREP

Unleash the power of your data to reduce your technical debt

The magic behind Recommendation Systems

Add a New Resource Group

Bovada Poker Catcher Hud

Bovada poker catcher hud online

Why You Need to be Writing Pseudocode

How can JAVA Performance tuning speed up applications?

Can’t install Linux/WSL from Microsoft Store, error 0x80073D05

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Agustinus Theodorus

Agustinus Theodorus

Loves to share his thoughts and opinions on the internet.

More from Medium

Xamarin.Forms Shell : Navigation

Library of RD.xml files for NativeAOT

Keyed Dependency Injection using .NET

Marrying Blazor and FHIR Questionnaire

Recursive code. Function receives all the items from the questionnaire. Based on the type of the item being passed in the function determines whether to call itself again or not.