Setting Base Path using ConfigurationBuilder

I was able to solve the issue. If you have not yet solved it, try the following in the project.json. Add the following:

"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final"

and it should work


Not sure if anyone still runs into this issue but I was able to address this in a dotnetcore console project (netcoreapp2.0) via:

dotnet add package Microsoft.Extensions.Configuration.Json

Try adding the following in your .csproj file:

<ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
</ItemGroup>

Just piling on with one more possible issue...

I had to add this:

<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.0.0" />

in order for this to compile:

var builder = new ConfigurationBuilder()
  .SetBasePath(Directory.GetCurrentDirectory())
  ...

Edit: I wrote this answer several months ago, but I'm pretty sure it was for a console app.


If you`re running a .NET Core 1.x or .NET Standard 1.x, you should run this command:

dotnet add package Microsoft.Extensions.Configuration.Json -v 1.1.1

If your project is inside another folder:

dotnet add .\src\MyProject package Microsoft.Extensions.Configuration.Json -v 1.1.1

...where MyProject is the name of the .csproj file.