Reputation: 306
struggling in Visual Studio 2019 in ASP.NET Core 3.1 (Win10 with Docker Desktop). I only want to change the "ASPNETCORE_ENVIRONMENT" from "Development" to "Production.
So what I've done was then to edit launchSettings.json
and edit the environment variables section:
"profiles": {
///cut other
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/version",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production",
},
"publishAllPorts": true,
"useSSL": false
}
}
When I then start debugging in Visual Studio I get: "Unable to configure HTTPS endpoint", unless it is working fine with "Development". Nevertheless the container shows in docker inspect still the "Development"
When I then add "ASPNETCORE_URLS": "http://+:80"
the container starts but still shows ASPNETCORE_ENVIRONMENT = Development. Also inside the docker when executing "ENV".
Don't really know, what else I can try.
Hope on your guidance.
Thanks in advance.
Upvotes: 1
Views: 4724
Reputation: 431
Maybe it is a UI Bug, you can check by
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
In my case, the application shows "Production",
but Visual Studio container debug tool shows "Developement".
Besides, you can add a "appsetting.Production.json" to double check the config is changing to Production, hope it helps.
Upvotes: 2
Reputation: 309
You can find this question helpful: ASPNETCORE_ENVIRONMENT in Docker
The proposed solution there - specify the environment in Dockerfile`s ENTRYPOINT:
ENTRYPOINT ["dotnet", "CoreDocker.dll", "--environment=Production"]
Upvotes: 0