Skip to content

Commit

Permalink
Merge pull request #350 from DigitalExcellence/bugfix/349-appsettings…
Browse files Browse the repository at this point in the history
…-load-fail

appsettings load in fail fix
  • Loading branch information
niraymak authored Jan 14, 2021
2 parents 0907679 + d95beff commit 6ba7f07
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
5 changes: 3 additions & 2 deletions API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ public static int Main(string[] args)
/// <returns>The webhostbuilder instance.</returns>
public static IWebHostBuilder CreateHostBuilder(string[] args)
{
// Appsettings is renamed because of an issue where the project loaded another appsettings.json
return WebHost.CreateDefaultBuilder(args)
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
IWebHostEnvironment env = hostingContext.HostingEnvironment;
config.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true);
config.AddJsonFile("appsettingsapi.json", true, true)
.AddJsonFile($"appsettingsapi.{env.EnvironmentName}.json", true, true);
config.AddEnvironmentVariables();
})
.UseSentry()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"ConnectionStrings": {
"DefaultConnection":
"Server=(LocalDb)\\MSSQLLocalDB;Database=Dex;Trusted_Connection=True;MultipleActiveResultSets=true"
"DefaultConnection": "Server=(LocalDb)\\MSSQLLocalDB;Database=Dex;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"App": {
"Frontend": {
Expand All @@ -11,10 +10,10 @@
},
"IdentityServer": {
"IdentityUrl": "https://localhost:5005",
"DevelopmentIdentityUrl": "https://localhost:5005"
"DevelopmentIdentityUrl": "https://localhost:5005"
},
"Swagger": {
"ClientId": "Swagger-UI"
"ClientId": "Swagger-UI"

}
},
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions NotificationSystem/NotificationSystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
<PackageReference Include="SendGrid" Version="9.21.2" />
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
<None Remove="appsettingsnotificationsystem.Development.json" />
<None Remove="appsettingsnotificationsystem.json" />
</ItemGroup>

<ItemGroup>
<Content Include="appsettings.Development.json">
<Content Include="appsettingsnotificationsystem.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<Content Include="appsettingsnotificationsystem.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
Expand Down
5 changes: 3 additions & 2 deletions NotificationSystem/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ internal class Program
private static void Main()
{
string environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
// Appsettings is renamed because of an issue where the project loaded another appsettings.json
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{environmentName}.json", true, true)
.AddJsonFile("appsettingsnotificationsystem.json", true, true)
.AddJsonFile($"appsettingsnotificationsystem.{environmentName}.json", true, true)
.AddEnvironmentVariables()
.Build();
Config config = configuration.GetSection("App").Get<Config>();
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ services:
container_name: rabbitmq
image: 'bitnami/rabbitmq:3.8.9'
environment:
- RABBITMQ_USERNAME=${App__RabbitMQ__Username}
- RABBITMQ_PASSWORD=${App__RabbitMQ__Password}
- RABBITMQ_USERNAME=test
- RABBITMQ_PASSWORD=test
ports:
- 5672:5672
- 5671:5671
Expand Down Expand Up @@ -55,11 +55,11 @@ services:
depends_on:
- rabbitmq
environment:
- App__RabbitMQ__Hostname=${App__RabbitMQ__Hostname}
- App__RabbitMQ__Username=${App__RabbitMQ__Username}
- App__RabbitMQ__Password=${App__RabbitMQ__Password}
- App__SendGrid__ApiKey=${App__SendGrid__ApiKey}
- App__SendGrid__EmailFrom=${App__SendGrid__EmailFrom}
- App__RabbitMQ__Hostname=rabbitmq
- App__RabbitMQ__Username=test
- App__RabbitMQ__Password=test
- App__SendGrid__ApiKey=test
- App__SendGrid__EmailFrom=test
stdin_open: true
tty: true
networks:
Expand All @@ -80,9 +80,9 @@ services:
- ASPNETCORE_HTTPS_PORT=5001
- ASPNETCORE_Kestrel__Certificates__Default__Password=xI90DrNea7M6UJFNDwip6t
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/dex-api.pfx
- App__RabbitMQ__Hostname=${App__RabbitMQ__Hostname}
- App__RabbitMQ__Username=${App__RabbitMQ__Username}
- App__RabbitMQ__Password=${App__RabbitMQ__Password}
- App__RabbitMQ__Hostname=rabbitmq
- App__RabbitMQ__Username=test
- App__RabbitMQ__Password=test
networks:
mssql-network:
rabbitmq-network:
Expand Down

0 comments on commit 6ba7f07

Please sign in to comment.