Reputation: 6852
Ok, so with a .net core app, if you set the environmentname in the publish profile, the docs here say it will set the app's environment
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/visual-studio-publish-profiles?view=aspnetcore-3.0
quote:
Include the property in the publish profile (.pubxml) or project file to set the app's environment:
How exactly will it do that? I thought that other than using visual studio, you had to set it at the machine level?
Upvotes: 2
Views: 1528
Reputation: 448
Include environment name in publish profile like below
<EnvironmentName>Development</EnvironmentName>
After publishing it results into ASPNETCORE_ENVIRONMENT in web.config in published code
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
If you have created different appSettings for each enviornment then based on ASPNETCORE_ENVIRONMENT from web.config, app uses respective app settings file for example appsettings.Development.json in this case
Upvotes: 4