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 ...
原创文章,作者:wure,如若转载,请注明出处:https://blog.ytso.com/277939.html