From 3a1c44c71e1290f739ad5cd3884e76b9fe7bf4bf Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 21 Sep 2022 10:02:07 -0400 Subject: [PATCH] Cleanup commandline config loading for .NET 6 --- src/Tgstation.Server.Host/ServerFactory.cs | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs index 9aa269ff22..6f5b450603 100644 --- a/src/Tgstation.Server.Host/ServerFactory.cs +++ b/src/Tgstation.Server.Host/ServerFactory.cs @@ -62,15 +62,32 @@ namespace Tgstation.Server.Host // values obtained via debugger var environmentJsonConfig = builder.Sources[2]; var envConfig = builder.Sources[3]; - var cmdLineConfig = builder.Sources[4]; - var baseYmlConfig = builder.Sources[5]; - var environmentYmlConfig = builder.Sources[6]; + + // CURSED + // https://github.com/dotnet/runtime/blob/30dc7e7aedb7aab085c7d9702afeae5bc5a43133/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs#L246-L249 + IConfigurationSource cmdLineConfig, baseYmlConfig, environmentYmlConfig; + if (args.Length == 0) + { + cmdLineConfig = null; + baseYmlConfig = builder.Sources[4]; + environmentYmlConfig = builder.Sources[5]; + } + else + { + cmdLineConfig = builder.Sources[4]; + baseYmlConfig = builder.Sources[5]; + environmentYmlConfig = builder.Sources[6]; + } builder.Sources[2] = baseYmlConfig; builder.Sources[3] = environmentJsonConfig; builder.Sources[4] = environmentYmlConfig; builder.Sources[5] = envConfig; - builder.Sources[6] = cmdLineConfig; + + if (cmdLineConfig != null) + { + builder.Sources[6] = cmdLineConfig; + } }); var setupWizardHostBuilder = CreateDefaultBuilder()