- Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathProgram.cs
22 lines (18 loc) · 708 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
usingMicrosoft.Extensions.Hosting.WindowsServices;
// https://stackoverflow.com/questions/69909593/asp-net-6-custom-webapplicationfactory-throws-exception
varoptions=newWebApplicationOptions
{
Args=args,
ContentRootPath=WindowsServiceHelpers.IsWindowsService()?AppContext.BaseDirectory:default,
WebRootPath="wwwroot",
ApplicationName=typeof(Program).Assembly.FullName
};
varbuilder=WebApplication.CreateBuilder(options);
builder.Host.UseWindowsService();
builder.WebHost.UseUrls("http://localhost:5300");
varapp=builder.Build();
app.Run(async context =>
{
awaitcontext.Response.WriteAsync($"This is hello world running from a Windows Service");
});
app.Run();