【发布时间】:2021-01-23 16:52:44
【问题描述】:
当我使用 dotnet publish 时,我的 .NET Core 2.1 应用程序无法读取 appsettings.json。我已验证 appsettings.json is 确实已复制到 out 文件夹。
$ dotnet publish
$ cd the/publish/directory
$ ls -l
MyApp.dll
...
Other dlls
...
appsettings.json
appsettings.Development.json
appsettings.Staging.json
runtimes/
web.config
wwwroot/
当我从发布文件夹运行dotnet MyApp.dll 时,我的任何应用设置都没有加载。关于为什么的任何想法?
编辑:appsettings 在我们的开发环境中被正确使用。
【问题讨论】:
-
它会在开发环境中加载应用程序设置吗?
-
是的。在我们的暂存环境中(我们不使用 dotnet publish)
标签: json .net .net-core publish appsettings