Reputation: 589
Using Angular project template with ASP.NET Core where An angular version is 5, Dotnet Core 2.1
here I tried to set my local Environment to "Production" as this command
$env:ASPNETCORE_ENVIRONMENT = "Production"
and then start DOTNET WATCH RUN
after this, I am still having my environment in "Development Mode"
So is there is any problem? I think I am doing right
Upvotes: 1
Views: 1669
Reputation: 93003
Inside of ./Properties/launchSettings.json
, you'll have something that looks like this:
{
...
"profiles": {
...
"DatingAppDemo": {
...
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Notice here that the value for ASPNETCORE_ENVIRONMENT
is set to Development
, which overrides the value you've set using the $env
command.
To resolve this, you have three options:
ASPNETCORE_ENVIRONMENT
from Development
to Production
in launchSettings.json
.dotnet watch run --no-launch-profile
, which instructs the dotnet
process to not load settings from launchSettings.json
.Add an additional profile to launchSettings.json
. e.g.:
"DatingAppDemoProduction": {
...
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
You can use this new profile with dotnet watch run --launch-profile DatingAppDemoProduction
.
Unless you decide to use option 2, you'll no longer need to set $env:ASPNETCORE_ENVIRONMENT
as this will be taken from launchSettings.json
as described.
Upvotes: 6