Mental Jetsam

By Peter Finch

.Net Core 2.0 Command Line Configuration

Posted by pcfinch on November 24, 2017

To configure a .Net Core 2.0 MVC application from the command line you need to add the following “UseConfiguration()” line to the “BuildWebHost()” function. You can then configure the app using the command line option.

public class Program
{
  public static void Main(string[] args) {
    BuildWebHost(args).Run();
  }
  public static IWebHost BuildWebHost(string[] args) => WebHost
    .CreateDefaultBuilder(args)
    .UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build())
    .UseStartup()
    .Build();
  }
}
Some example command line options are :

--server.urls http://*:80
--urls http://localhost:500;http://localhost:501

References

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: