Skip to content

Commit

Permalink
#6260 Added support of environment specific appsettings.json files
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanovM committed May 19, 2022
1 parent c6b86dd commit b45bd3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Expand Up @@ -9,5 +9,11 @@ public static partial class NopConfigurationDefaults
/// Gets the path to file that contains app settings
/// </summary>
public static string AppSettingsFilePath => "App_Data/appsettings.json";

/// <summary>
/// Gets the path to file that contains app settings for specific hosting environment
/// </summary>
/// <remarks>0 - Environment name</remarks>
public static string AppSettingsEnvironmentFilePath => "App_Data/appsettings.{0}.json";
}
}
5 changes: 5 additions & 0 deletions src/Presentation/Nop.Web/Program.cs
Expand Up @@ -8,6 +8,11 @@

builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
builder.Configuration.AddJsonFile(NopConfigurationDefaults.AppSettingsFilePath, true, true);
if (!string.IsNullOrEmpty(builder.Environment?.EnvironmentName))
{
var path = string.Format(NopConfigurationDefaults.AppSettingsEnvironmentFilePath, builder.Environment.EnvironmentName);
builder.Configuration.AddJsonFile(path, true, true);
}
builder.Configuration.AddEnvironmentVariables();

//Add services to the application and configure service provider
Expand Down

0 comments on commit b45bd3f

Please sign in to comment.