2
核心1.x的配置已经在这里找到答案DOTNET的酷睿2控制台应用程序配置
ASP.NET Core configuration for .NET Core console application
不幸的是,核心2.0.0 API和体系结构略有改变,并通过the looks of this article它使用依赖注入的现在启动类(基于WebAPI的项目),分配更简单。
但我不知道如何在控制台应用程序上做到这一点,因为没有底层的DI。当我尝试使用下面的代码没有任何的方法存在于新的2.0.0
var builder = new ConfigurationBuilder()
.AddJsonFile($"appsettings.json", true, true) -ERROR
.AddJsonFile($"appsettings.{environmentName}.json", true, true) -ERROR
.AddEnvironmentVariables(); -ERROR
是否有任何身体知道如何添加appsettings.json
到ConfigurationBuilder?