From fa28df0a09cc594ebdaa1a728ed176a5a36df2cd Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 7 Feb 2021 16:52:35 -0600 Subject: allow loading config from arbitrary dir --- src/slskd/Program.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 373cad67..7095a716 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -1,4 +1,4 @@ -namespace slskd +namespace slskd { using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; @@ -22,6 +22,8 @@ { public static IConfigurationBuilder AddConfigurationProviders(this IConfigurationBuilder builder, string environmentVariablePrefix, string configurationFile) { + configurationFile = Path.GetFullPath(configurationFile); + return builder .AddDefaultValues( map: Options.Map.Select(o => o.ToDefaultValue())) @@ -29,9 +31,10 @@ prefix: environmentVariablePrefix, map: Options.Map.Select(o => o.ToEnvironmentVariable())) .AddYamlFile( - path: Path.Combine(AppContext.BaseDirectory, configurationFile), + path: Path.GetFileName(configurationFile), optional: true, - reloadOnChange: false) + reloadOnChange: false, + provider: new PhysicalFileProvider(Path.GetDirectoryName(configurationFile), ExclusionFilters.None)) .AddCommandLine( commandLine: Environment.CommandLine, map: Options.Map.Select(o => o.ToCommandLineArgument())); -- cgit v1.2.3