I'm trying add the ConfigurationBuilder in an .net core console application
I'm getting this exception when running the code below.
I checked and in the Directory.GetCurrentDirectory()
the file appsettings.json is present.
System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'Microsoft.Extensions.FileProviders.Physical, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. Source=Microsoft.Extensions.Configuration.FileExtensions StackTrace: at Microsoft.Extensions.Configuration.FileConfigurationExtensions.SetBasePath(IConfigurationBuilder builder, String basePath) at DashboardService.Program.Main(String[] args)
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
You will have to add Microsoft.Extensions.FileProviders.Physical to your project. https://www.nuget.org/packages/microsoft.extensions.fileproviders.physical/ Here you can take it. Hope it helps
User contributions licensed under CC BY-SA 3.0