You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.TypeInitializationException: The type initializer for 'Submission#0' threw an exception. ---> System.IO.FileNotFoundException: The configuration file 'config.json' was not found and is not optional. The physical path is '/usr/local/lib/dotnet-script/config.json'.
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Submission#0..cctor() in /Users/gldraphael/projects/misc/vi/config.csx:line 9
--- End of inner exception stack trace ---
at Submission#0.<<Initialize>>d__0.MoveNext() in /Users/gldraphael/projects/misc/vi/config.csx:line 14
--- End of stack trace from previous location where exception was thrown ---
at Dotnet.Script.Core.ScriptRunner.Execute[TReturn](String dllPath, IEnumerable`1 commandLineArgs) in C:\projects\dotnet-script\src\Dotnet.Script.Core\ScriptRunner.cs:line 58
This is related to how Microsoft.Extensions.Logging resolves the full path to the config file when you give it a relative path. My guess here is that it is resolved based on the entry assembly which is dotnet-script.
There is really not much we can do about this other than providing the full path to the config file.
Like this:
public static var config = new ConfigurationBuilder()
.AddJsonFile(Path.GetFullPath("config.json"), optional: false, reloadOnChange: true)
.Build()
.Get<Config>();
Stacktrace:
Source:
File structure:
However, another script that accesses a file works just fine:
serilog.csx
Possibly related: #435
The text was updated successfully, but these errors were encountered: