diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-02-07 16:52:35 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-02-07 16:52:35 -0600 |
| commit | fa28df0a09cc594ebdaa1a728ed176a5a36df2cd (patch) | |
| tree | 024f84f03c542c3f91aa1eae9ea83ba610eefbc8 /src/slskd | |
| parent | 17e5a9df9b0d494574baa7d33905952ac490d792 (diff) | |
| download | slskd-fa28df0a09cc594ebdaa1a728ed176a5a36df2cd.tar.gz | |
allow loading config from arbitrary dir
Diffstat (limited to 'src/slskd')
| -rw-r--r-- | src/slskd/Program.cs | 9 |
1 files 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())); |
