我终于想通了!
诀窍是右键单击项目,转到属性,然后选择调试选项卡。接下来,在 Profile 下,我选择了我的 projects.json 中定义的命令的名称:“watch”。选择后,我单击按环境变量添加,并添加名称/值对 ASPNETCORE_ENVIRONMENT 和 Development。

这实际上是在解决方案资源管理器的属性下上传 launchSettings.json 文件。该文件也可以手动编辑。输出看起来像这样:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56846/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"LendingTree.CreditCards.Web": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Watcher Development": {
"commandName": "Watcher Development",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}