ConfigurationBuilder does not contain a definition for SetBasePath
Issue-
So , while working with .Net core you often need to read app json file from siteroot to access connection string and other keys available there. So in previous versions we used to use Configuration Builder for reading json file using SetBasePath Method.We used to write
new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appSettings.json").Build();
But the same code becomes non reachable when it comes to .Net core as you receive error which is shown in below image saying 'ConfigurationBuilder' does not contain a definition for 'SetBasePath' . So will see how to make this work in .Net core 3.1.
So, This issue is basically because of a missing package in .Net core 3. So for this you have to add Microsoft.Extension.Configuration.json in your project. You can find this package on Nuget package as shown in image.
You can also install this package using Package Manager console using this command. For more reference you can have a look at https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json and then have a look at installation steps.
Install-Package Microsoft.Extensions.Configuration.Json -Version 5.0.0
So , after you successfully install this package you can check SetBasePath method will start working as expected. You can have a look at below image.
So ,you can follow the steps and this is how you can read app.json file in .Net core 3.1.