.NET6 运行WindowsService
作者:互联网
1、安装nuget包
Microsoft.Extensions.Hosting.WindowsServices
2、修改Program.cs
public static void Main(string[] args)
{
var options = new WebApplicationOptions
{
Args = args,
ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
};
var builder = WebApplication.CreateBuilder(options);
builder.Host.UseWindowsService();
builder.WebHost.UseUrls("http://*:8010");
....
}
3、安装
sc create ...
标签:UseUrls,WindowsService,args,options,var,NET6,安装,builder,运行 来源: https://www.cnblogs.com/gaobing/p/16534834.html