From 498e8375f45803e1f4ff66e1fb55a1f84a0b91bd Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 24 Jun 2020 15:20:30 -0400 Subject: [PATCH] Fix runner builds --- src/Tgstation.Server.Host.Console/Program.cs | 52 +++++++++---------- .../Tgstation.Server.Host.Console.csproj | 2 +- .../Tgstation.Server.Host.Service.csproj | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/Tgstation.Server.Host.Console/Program.cs b/src/Tgstation.Server.Host.Console/Program.cs index 54cdad151b..ab8c475b50 100644 --- a/src/Tgstation.Server.Host.Console/Program.cs +++ b/src/Tgstation.Server.Host.Console/Program.cs @@ -24,40 +24,36 @@ namespace Tgstation.Server.Host.Console /// A representing the running operation internal static async Task Main(string[] args) { - using (var loggerFactory = new LoggerFactory()) - { - var arguments = new List(args); - var trace = arguments.Remove("--trace-host-watchdog"); - var debug = arguments.Remove("--debug-host-watchdog"); + using var loggerFactory = new LoggerFactory(); + var arguments = new List(args); + var trace = arguments.Remove("--trace-host-watchdog"); + var debug = arguments.Remove("--debug-host-watchdog"); #pragma warning disable CS0618 // Type or member is obsolete - loggerFactory.AddConsole(trace ? LogLevel.Trace : debug ? LogLevel.Debug : LogLevel.Information, true); + loggerFactory.AddConsole(); #pragma warning restore CS0618 // Type or member is obsolete - if (trace && debug) - { - loggerFactory.CreateLogger(nameof(Program)).LogCritical("Please specify only 1 of --trace-host-watchdog or --debug-host-watchdog!"); - return; - } + if (trace && debug) + { + loggerFactory.CreateLogger(nameof(Program)).LogCritical("Please specify only 1 of --trace-host-watchdog or --debug-host-watchdog!"); + return; + } - using (var cts = new CancellationTokenSource()) + using var cts = new CancellationTokenSource(); + void AppDomainHandler(object a, EventArgs b) => cts.Cancel(); + AppDomain.CurrentDomain.ProcessExit += AppDomainHandler; + try + { + System.Console.CancelKeyPress += (a, b) => { - void AppDomainHandler(object a, EventArgs b) => cts.Cancel(); - AppDomain.CurrentDomain.ProcessExit += AppDomainHandler; - try - { - System.Console.CancelKeyPress += (a, b) => - { - b.Cancel = true; - cts.Cancel(); - }; - await WatchdogFactory.CreateWatchdog(loggerFactory).RunAsync(false, arguments.ToArray(), cts.Token).ConfigureAwait(false); - } - finally - { - AppDomain.CurrentDomain.ProcessExit -= AppDomainHandler; - } - } + b.Cancel = true; + cts.Cancel(); + }; + await WatchdogFactory.CreateWatchdog(loggerFactory).RunAsync(false, arguments.ToArray(), cts.Token).ConfigureAwait(false); + } + finally + { + AppDomain.CurrentDomain.ProcessExit -= AppDomainHandler; } } } diff --git a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj index 211e428052..d71f4dfdcd 100644 --- a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj +++ b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj @@ -27,7 +27,7 @@ all compile; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj index 661744af04..be8411533d 100644 --- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj +++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj @@ -28,7 +28,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers