简体   繁体   中英

How do you install a .NET 6 Windows Service (Worker Service) using a Visual Studio Installer project?

I Have a Worker Service written in c# that needs to be installed as a Windows Service (configured by calling the UseWindowsService method).

This guide specifies how to create an installer for a .NET 6 application, but this installer only copies the app's files.

How can I install the service contained in the executable?

You can use sc create command in order to register service. Like this:

sc.exe create NewService binpath= c:\windows\system32\NewServ.exe

PS pay attention, there is mandatory space after binpath=

There's a lot more steps to make it a service you can create. See https://learn.microsoft.com/en-us/do.net/core/extensions/windows-service

I was missing some of the nuget packages and other hand edits to the csproj file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM