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