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) {
  public static IWebHost BuildWebHost(string[] args) => WebHost
    .UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build())
Some example command line options are :

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


Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

%d bloggers like this: