Hello Guys, I noticed that in the native code of server side code (angular 5 .Net core) to read the appsettings.json file using this code JObject.Parse(File.ReadAllText("appsettings.json")); Is this working if I create a file appsettings.Production.json will this read the correct production file automatically if I change the ASPNETCORE_ENVIRONMENT to production? Or it is going to find appsettings.json on the drive? How does this work?
Regards
7 Answer(s)
-
0
Reading of appsetting.json with environment variable is done at <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Configuration/AppConfigurations.cs#L34">https://github.com/aspnetzero/aspnet-ze ... ons.cs#L34</a>
-
0
<cite>ryancyq: </cite> Reading of appsetting.json with environment variable is done at <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Configuration/AppConfigurations.cs#L34">https://github.com/aspnetzero/aspnet-ze ... ons.cs#L34</a>
ok thanks but does that mean that if you have a custom appsettings.environment.json, with the above code it will loaded natively the correct file? Do I need to change the code for it to work properly?
-
0
I create a appsettings.staging.json file change the environment variable ASPNETCORE_ENVIRONMENT to staging but when I do an update-database it is still pointing to the dev environment. The default appsettings file...How should I do
-
0
<cite>SquaresUnion: </cite> I create a appsettings.staging.json file change the environment variable ASPNETCORE_ENVIRONMENT to staging but when I do an update-database it is still pointing to the dev environment. The default appsettings file...How should I do
Yes. Given a custom appsettings.environment.json, if you set the environment variable correctly, it will be loaded automatically.
-
0
<cite>SquaresUnion: </cite> I create a appsettings.staging.json file change the environment variable ASPNETCORE_ENVIRONMENT to staging but when I do an update-database it is still pointing to the dev environment. The default appsettings file...How should I do
OK I am reading the doc. What I am trying to do will never work. I got the right way to proceed thanks
-
0
The Update-Datebase command will not use the environment.
See: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/EntityFrameworkCore/AbpZeroTemplateDbContextFactory.cs#L15">https://github.com/aspnetzero/aspnet-ze ... ory.cs#L15</a>
<a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Configuration/AppConfigurations.cs#L17">https://github.com/aspnetzero/aspnet-ze ... ons.cs#L17</a>
-
0
<cite>maliming: </cite> The Update-Datebase command will not use the environment.
See: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/EntityFrameworkCore/AbpZeroTemplateDbContextFactory.cs#L15">https://github.com/aspnetzero/aspnet-ze ... ory.cs#L15</a>
<a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Configuration/AppConfigurations.cs#L17">https://github.com/aspnetzero/aspnet-ze ... ons.cs#L17</a>
Yes I saw that. It working for me now. Great thanks for you quick answer.
Regards