我正在使用 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"
}
}
}
}
当我设置 "ASPNETCORE_ENVIRONMENT": "Development"
时,我不确定为什么 dotnet
在“生产”中运行应用程序。
这在 ASP.NET Core RC1 中有效。我错过了什么?
最佳答案
从 Visual Studio 启动时使用 launchsettings.json,但从命令行 dotnet.exe 启动时不使用。
在调用 dotnet run
之前在控制台上设置环境变量。
设置 ASPNETCORE_ENVIRONMENT=开发
关于asp.net-core - 在 "Development"环境中运行ASP.NET Core应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37413374/