feat: Add Windows Service hosting support

- Add Microsoft.Extensions.Hosting.WindowsServices package
- Add HostingOptions:UseWindowsService configuration flag to appsettings.json
- Configure Program.cs to optionally run as Windows Service based on config
- IIS hosting continues to work by default (UseWindowsService=false)
- Delete obsolete Worker.cs that was conflicting with ProfileManager
This commit is contained in:
2026-07-12 00:23:59 +02:00
parent 59bef13f5d
commit d50232b0bb
3 changed files with 10 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
<PackageReference Include="Hangfire.InMemory" Version="1.0.0" />
<PackageReference Include="Hangfire.SqlServer" Version="1.8.23" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

View File

@@ -7,6 +7,12 @@ using Microsoft.Data.SqlClient;
var builder = WebApplication.CreateBuilder(args);
// Configure Windows Service hosting if enabled
if (builder.Configuration.GetValue<bool>("HostingOptions:UseWindowsService"))
{
builder.Host.UseWindowsService();
}
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddHostedService<ProfileManager>();

View File

@@ -9,6 +9,9 @@
"SDD-VMP04-SQL17": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
},
"AllowedHosts": "*",
"HostingOptions": {
"UseWindowsService": false
},
"Hangfire": {
"InMemory": true
},