Skip to content

Commit

Permalink
use app.Environment.Isdevelopment to judge current env
Browse files Browse the repository at this point in the history
  • Loading branch information
zedy committed Feb 20, 2023
1 parent 78dfbd7 commit a7b4199
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@

var builder = WebApplication.CreateBuilder(args);

var detectEnvBuilder = WebApplication.CreateBuilder(args);

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)
Microsoft.eShopWeb.Infrastructure.Dependencies.ConfigureServices(builder.Configuration, builder.Services);
}
Expand Down
1 change: 0 additions & 1 deletion src/Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"IdentityConnection": "Server=(localdb)\\mssqllocaldb;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;"
},
"CatalogBaseUrl": "",
"Environment": "Local",
"Logging": {
"IncludeScopes": false,
"LogLevel": {
Expand Down

0 comments on commit a7b4199

Please sign in to comment.