-
Notifications
You must be signed in to change notification settings - Fork 308
Cannot set self-hosting url using command line argument and hosting.json after UseDefaultHostingConfiguration removed, #740
Comments
If you want to support command line arguments then just it's 2 calls instead of one. The decision was made to remove the shortcut because the method name was pretty confusing and as more code moved into the application, having some of those defaults weren't important anymore. You never have to call AddEnvironmentVariables because that's done by default now. If you want command line args then the code looks like this: There's no longer a "default hosting configuration" |
@davidfowl But there is a bug, the call order becomes important. Here is an example: var builder = new ConfigurationBuilder()
.AddCommandLine(args)
.AddJsonFile("hosting.json", optional: true)
.AddJsonFile("config.json"); Command line arg ‘server. urls’ will be ignored. This is not the desired behavior as command line args are expected to always override settings in configuration files. |
Are you saying you want the extension method back so that it can order things properly for your app? The difference in thinking here comes from the fact that you control your hosting wire up. That code in now part of the application.
|
I understand your explanation and don't want extension method back. But I think command line args should be used/read first. Or in the following code: |
Sounds fine, put them last 😄 . I don;t know how you'd expect that to be a compiler error. |
@davidfowl Yes. It will never be a compiler error. I hope command line args are re-ordered internally, so user doesn't have to remember to put AddCommandLine(args) last every time. |
You want the command line arguments to be reordered internally where? |
@davidfowl You know I mean using command line settings first internally always. |
Uh oh!
There was an error while loading. Please reload this page.
After UseDefaultHostingConfiguration removed,
"dotnet run /server.urls http://xyz:5000" does not work any more. Neither does ""server.urls": "http://xyz:5000/"" in hosting.json. Only "UseUrls("http://xyz:5000")" in code works.
The following lines in Startup() seem dummy:
Also 'args' is not available in Startup(), assigning it in main() to another static variable just for it is too much.
The text was updated successfully, but these errors were encountered: