在"开发"环境中运行ASP.NET Core应用程序

Mig*_*ura 9 project.json asp.net-core .net-core-rc2

我正在使用ASP.NET Core RC2,当我运行dotnet run我的应用程序时总是在"生产"中运行.我无法将其更改为"开发".

我有以下launchSettings.json文件:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:26088/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MVCCoreRc2App": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我不确定为什么dotnet在设置时在"生产"中运行应用程序"ASPNETCORE_ENVIRONMENT": "Development".

这在ASP.NET Core RC1中有效.我错过了什么?

Tra*_*her 11

从Visual Studio启动时使用launchsettings.json,但不是从命令行dotnet.exe启动.

在控制台上,在调用之前设置环境变量dotnet run.

set ASPNETCORE_ENVIRONMENT=Development

  • 这似乎不是我的永久解决方案.每次我需要设置这个变量.我正在使用IIS托管应用程序是什么? (4认同)