dotnet new webset ASPNETCORE_URLS=http://127.0.0.1:0dotnet run (note ASPNETCORE_URLS is ignored)> dotnet run
Using launch settings from D:\Temp\foo2\Properties\launchSettings.json...
Hosting environment: Development
Content root path: D:\Temp\foo2
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
dotnet run --no-launch-profile (note ASPNETCORE_URLS is used)> dotnet run --no-launch-profile
Hosting environment: Production
Content root path: D:\Temp\foo2
Now listening on: http://127.0.0.1:50897
Application started. Press Ctrl+C to shut down.
What's in your launchSettings.json? It sounds like its setting ASPNETCORE_URLS for you.
The launchSettings.json was generated by dotnet new. The behavior may be by design, I was just surprised to see ASPNETCORE_URLS ignored in our default template workflow.
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54630",
"sslPort": 44359
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"web": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Interesting, I never knew the launchsettings.json overrides the environment variables currently in the system but it is documented here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.1. So I assume this is "as designed"? Though I do think this is an odd default behaviour and could be difficult to discover why.
Yes, that sounds like it's working as expected. It wants the server to start with the urls specified in the launchsettings and the easiest way to do that is to set ASPNETCORE_URLS. This is specific to dev environments.
Note that if you specified urls in any of the other supported ways (config file, command line, code, etc.) most of those would also override ASPNETCORE_URLS.
I don't have an opinion either way, but I do want to point out this is a user experience regression from 2.0. In CLI 2.1.105, no launchSettings.json is generated by default, so setting ASPNETCORE_URLS works.
@DamianEdwards , @davidfowl , @muratg: Any opinions on whether we should change the currently 2.1 experience?
This is for sure an experience regression. I think the new behavior is very odd. I think config files shouldn't override environment variables. I think we should consider fixing it for RTM (if there's a simple low risk fix.)
Note this logic is built into the dotnet run tooling, it's not any code from the aspnet org. This bug would need to be moved accordingly.
I assume we'd like to bring this one to shiproom?
Should this be moved to https://github.com/dotnet/cli first?
@livarcocc could you take a quick look before I move it over?
@vijayrkn can you take a look? your team has maintained this code on the CLI so far.
@mlorbetske - do you know who else have context on this?
Bill would probably be the best person to take a look
Get Outlook for iOShttps://aka.ms/o0ukef
From: Vijay Ramakrishnan notifications@github.com
Sent: Tuesday, May 1, 2018 12:48 PM
Subject: [aspnet/MetaPackages] ASPNETCORE_URLS environment variable is ignored by "dotnet run" (#264)
To: aspnet/MetaPackages metapackages@noreply.github.com
Cc: Mike Lorbetske mike.lorbetske@n3-p.com, Mention mention@noreply.github.com
@mlorbetskehttps://github.com/mlorbetske - do you know who else have context on this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/aspnet/MetaPackages/issues/264#issuecomment-385737959, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABWXUd3gmK14WUsmBpf5k6uyyGLEFuWLks5tuJ_YgaJpZM4TrH2z.
@BillHiebert
I have no context on the code in dotnet run, but this seems by design to me as the applicationUrls section in launchsettings.json file will cause it to use those settings. I assume if this didn't repro before, it was because either there wasn't a launchsettings.json file, or the dotnet run code never honored the settings in it. I don't think reverting it is the right behavior.
The proposal is not to revert it, but to check if ASPNETCORE_URLS is defined and avoid overwriting it.
Do not use set at the beggining
ASPNETCORE_URLS=http://127.0.0.1:8080 dotnet run
For me to run successfully with a specified port (44360) on SSL on Windows 10 from cmd:
1.dotnet dev-certs https --trust (if not installed)
2.set ASPNETCORE_URLS=https://localhost:44360
3.dotnet run --no-launch-profile
This is controlled in the CLI and VS, so it should be filed against dotnet/cli and the VS feedback tool. We don't control this behavior in ASP.NET Core, it's the CLI/VS launcher that is overriding the variable.
Most helpful comment
https://github.com/dotnet/cli/blob/d0780d81e571abfcdcd1ed2ab85f0cc4a155528e/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs#L18-L21