📜  hostbuilder添加环境变量——C编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:34.311000             🧑  作者: Mango

代码示例1
var builder = new HostBuilder();
        builder
        .ConfigureHostConfiguration(config =>
         {
             config.AddEnvironmentVariables(prefix:"DOTNETCORE_");
         })
         .ConfigureAppConfiguration((context, config) =>
         {
             config.AddJsonFile("appsettings.json", optional: false);
             config.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true);
         })