简体   繁体   English

如何使用 Visual Studio 安装程序项目安装 .NET 6 Windows 服务(Worker Service)?

[英]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).我有一个写在 c# 中的 Worker 服务,需要安装为 Windows 服务(通过调用UseWindowsService方法配置)。

This guide specifies how to create an installer for a .NET 6 application, but this installer only copies the app's files. 本指南指定如何为 .NET 6 应用程序创建安装程序,但此安装程序仅复制应用程序的文件。

How can I install the service contained in the executable?如何安装可执行文件中包含的服务?

You can use sc create command in order to register service.您可以使用sc create命令来注册服务。 Like this:像这样:

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

PS pay attention, there is mandatory space after binpath= PS注意, 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参见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.我丢失了一些 nuget 包和对 csproj 文件的其他手动编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Visual Studio为.net Windows服务创建安装程序 - How to create an installer for a .net Windows Service using Visual Studio 如何使用 Visual Studio 代码为 .NET Core 的工作人员服务创建安装程序 - How to create an installer for worker service of .NET Core using visual studio code Visual Studio安装程序项目扩展-安装服务 - Visual Studio Installer Projects Extension - Install a Service 将参数发送到Windows Service Installer Visual Studio - Send parameters to Windows Service Installer Visual Studio 在 Visual Studio 2022 上为 windows 服务创建安装程序 - Creating an installer for a windows service on Visual Studio 2022 安装 .NET Core 3.0 Worker Service 和 WiX 作为 Windows 服务 - Install .NET Core 3.0 Worker Service with WiX as Windows Service 安装在Visual Studio中创建的Windows服务 - Install Windows Service created in Visual Studio 如何使用Visual Studio 2010将Windows控制台应用程序C#项目更改为Windows Service? - How to change Windows console app C# project into Windows Service using Visual Studio 2010? 如果由 Visual Studio 安装程序安装,则无法调试 Windows 服务 - Can't debug Windows Service if it's installed by Visual Studio Installer 使用 Visual Studio 安装程序项目将 ASP .NET 核心服务安装到 IIS - Installing ASP .NET Core service to IIS using Visual Studio Installer Projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM