UseWindowsService

This commit is contained in:
Mike Phares 2022-03-29 12:18:07 -07:00
parent 8d039fc41d
commit 76d103e0ec
2 changed files with 4 additions and 0 deletions

View File

@ -33,6 +33,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" /> <PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" /> <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />

View File

@ -18,6 +18,7 @@ public class Program
if (string.IsNullOrEmpty(assemblyName)) if (string.IsNullOrEmpty(assemblyName))
throw new Exception(); throw new Exception();
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args); WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
_ = webApplicationBuilder.Host.UseWindowsService();
AppSettings appSettings = Models.Stateless.AppSettings.Get(webApplicationBuilder.Configuration); AppSettings appSettings = Models.Stateless.AppSettings.Get(webApplicationBuilder.Configuration);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName)) if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!"); throw new Exception("Working directory name must have a value!");