Setting environment variables in .NET Core 2.0

后端 未结 4 711
傲寒
傲寒 2020-12-14 02:58

I am trying to setting up multiple environments in my .NET Core 2.0 application. See my code below.

Configuration file (Launch.JSON)

\"configuratio         


        
4条回答
  •  [愿得一人]
    2020-12-14 03:02

    You can update your launchsettings.json to include a 'Development' profile and then run:

    dotnet run --launch-profile "Development"
    

    For further details on configuration of the launchSettings.json file see Working with multiple environments

    Note that the commandName would probably need to be "Project" (I haven't really tried this much). Example launchSettings.json as follows:

    {
      "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
          "applicationUrl": "http://localhost:19882/",
          "sslPort": 0
        }
      },
      "profiles": {
        "Development": {
          "commandName": "Project",
          "launchBrowser": true,
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          }
        }
      }
    }
    

提交回复
热议问题