Closed
Description
I set DOTNET_ENVIRONMENT to "Development" but app still thinks is "Production"
#r "sdk:Microsoft.NET.Sdk.Web"
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
var builder = WebApplication.CreateBuilder();
var app = builder.Build();
app.Logger.LogInformation($"EnvironmentName: {app.Environment.EnvironmentName}"); // EnvironmentName: Production
// above should be Development
app.Logger.LogInformation($"IsDevelopment(): {app.Environment.IsDevelopment()}"); // IsDevelopment(): False
// above should be True
string env = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT", EnvironmentVariableTarget.Machine);
app.Logger.LogInformation($"env: {env}"); // env: Development
// above shows that env var is set
app.MapGet("/", () => "Hello world");
app.Run("http://localhost:5178");
Metadata
Metadata
Assignees
Labels
No labels