Can't make a function call in in spite of the using statement and extension needed

So I wanted to be able to choose my environment when running dotnet (an .net core mvc-project) from the terminal. I found this post and thought the second highest answer was a neat way of solving it, in short:

Replacing the Program class body with the following:

private static readonly Dictionary<string, string> defaults =
new Dictionary<string, string> {
    { WebHostDefaults.EnvironmentKey, "development" }
};

public static void Main(string[] args)
{
    var configuration =
        new ConfigurationBuilder()
            .AddInMemoryCollection(defaults)
            .AddEnvironmentVariables("ASPNETCORE_")
            .AddCommandLine(args)
            .Build();

    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<Startup>()
        .Build();

    host.Run();
}

Then running:

dotnet run environment=development
dotnet run environment=staging

So I pasted it, and it said I need to add a using statment

using Microsoft.Extensions.Configuration;

Still got this error message:

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

I'm a bit at loss for what could be the problem. I mean, here's the definition of AddCommandLine(IConfigurationBuilder, String[]) with namespace Microsoft.Extensions.Configuration?

Jon Skeet
people
quotationmark

Although the namespace is Microsoft.Extensions.Configuration, the extension is in the Microsoft.Extensions.Configuration.CommandLine assembly, which is in the Microsoft.Extensions.Configuration.CommandLine package. You need to add a dependency on that package.

people

See more on this question at Stackoverflow