Build failing on .net Core app due to missing definition
<p>I'm trying to build my .NET Core app from the CLI using <code>dotnet build</code>, but every single time I get this error: </p>

<blockquote>
  <p>'IConfigurationBuilder' does not contain a definition for 'AddEnvironmentVariables' and no extension method 'AddEnvironmentVariables' accepting a first argument of type 'IConfigurationBuilder' could be found (are you missing a using directive or an assembly reference?)</p>
</blockquote>

<p>This is my <code>ConfigureServices</code> method in <code>Startup.cs</code> where the problem is happening:</p>

<pre><code>    public void ConfigureServices(IServiceCollection services)
    {
        var builder = new ConfigurationBuilder()
            .AddJsonFile("config.json")
            .AddEnvironmentVariables()
            .Build();

        services.AddEntityFrameworkSqlServer()
             .AddDbContext&lt;MyContext&gt;(options =&gt;
                 options.UseSqlServer(builder["Data:MyContext:ConnectionString"]));

        services.AddIdentity&lt;ApplicationUser, ApplicationRole&gt;()
            .AddEntityFrameworkStores&lt;MyContext&gt;()
            .AddDefaultTokenProviders()
            .AddOpenIddictCore&lt;Application&gt;(config =&gt; config.UseEntityFramework());

        services.AddMvc();

        services.AddScoped&lt;OpenIddictManager&lt;ApplicationUser, Application&gt;, CustomOpenIddictManager&gt;();
    }
</code></pre>

<p>Looking at <a href="https://github.com/openiddict/openiddict-core/blob/dev/samples/Mvc.Server/Startup.cs" rel="noreferrer">this example</a> I see nothing obviously wrong with my <code>Startup.cs</code>.</p>

<p><strong>Update</strong>
My <code>project.json</code> file:</p>

<pre><code>{
  "compilationOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "dependencies": {
    "AspNet.Security.OAuth.Validation": "1.0.0-alpha1-*",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-*",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-*",
    "OpenIddict.Core": "1.0.0-*",
    "OpenIddict.EF": "1.0.0-*"
  },

  "frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.ComponentModel": { "type": "build" }
      }
    },

    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-*"
        }
      },

      "imports": [
        "dnxcore50",
        "portable-net451+win8"
      ]
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-rc2-*",
      "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
    }
  },

  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
  },

  "content": [
    "wwwroot",
    "Views",
    "config.json",
    "web.config"
  ],

  "exclude": [
    "wwwroot",
    "node_modules"
  ],

  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}
</code></pre>

<p><strong>Oct 2018 Update:</strong>
This problem does not occur when creating a new .NET Core 2.1 app in the latest build of VS 2017. Everything is now at a long-stable version since I asked this question.</p>