use app.Environment.Isdevelopment to judge current env

This commit is contained in:
zedy
2023-02-20 16:29:08 +08:00
parent 78dfbd70e1
commit a7b41991cb
2 changed files with 4 additions and 3 deletions

View File

@@ -21,11 +21,13 @@ using Microsoft.Extensions.Diagnostics.HealthChecks;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var detectEnvBuilder = WebApplication.CreateBuilder(args);
builder.Logging.AddConsole(); builder.Logging.AddConsole();
var env = builder.Configuration["Environment"]; var detectEnvApp = detectEnvBuilder.Build();
if (env == "Local"){ if (detectEnvApp.Environment.IsDevelopment() || detectEnvApp.Environment.EnvironmentName == "Docker"){
// Configure SQL Server (local) // Configure SQL Server (local)
Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services); Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services);
} }

View File

@@ -8,7 +8,6 @@
"IdentityConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;" "IdentityConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;"
}, },
"CatalogBaseUrl": "", "CatalogBaseUrl": "",
"Environment": "Local",
"Logging": { "Logging": {
"IncludeScopes": false, "IncludeScopes": false,
"LogLevel": { "LogLevel": {