crayden
crayden

Reputation: 2270

Why is "ASPNETCORE_ENVIRONMENT: Development" not working?

An ASP.NET Core application has been created using the following commands.

dotnet new globaljson --sdk-version 2.2.402
dotnet new mvc

After writing some code and running the application, there was an error in the code. Using the command line, the application is started with dotnet run, and the console outputs Hosting environment: Development. As seen in the image below, error messages are not printing. The error message asks to set "ASPNETCORE_ENVIRONMENT" to "Development", but it is already set in both launch.json and lanchSettings.json.

enter image description here

What needs to be done for ASP.NET Core to output more detailed information about the error that occurred?

.vscode/launch.json

{
   "version": "0.2.0",
   "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/PNoAWebApp.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"                
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}

Upvotes: 2

Views: 4026

Answers (1)

sashoalm
sashoalm

Reputation: 79467

This probably won't help anyone else, but in my case I had added an extra space because I had copied it from Process Explorer, so it ASPNETCORE_ENVIRONMENT was set to "Development " instead of "Development".

If you have this issue, double check that there are no extra spaces.

Upvotes: 1

Related Questions