'ConfigurationBuilder' does not contain a definition for 'AddJsonFile'

Solution 1:

The AddJsonFile extension method is available in NuGet:

  • Microsoft.Extensions.Configuration.Json

When building an ASP.NET Core application, which usually references Microsoft.AspNetCore.App (or, historically, Microsoft.AspNetCore.All), you get this "for free".

When building a console application, or something that doesn't reference the metapackages, you need an explicit reference to Microsoft.Extensions.Configuration.Json.