How to publish environment specific appsettings in .Net core app?

后端 未结 12 2437
刺人心
刺人心 2020-12-04 15:33

I have 3 environment specific appsettings files in my .Net core application

in project.json I have setup publishOptions

12条回答
  •  萌比男神i
    2020-12-04 15:47

    You need to actually add the environment variables, according the official tutorial:

    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: false, reloadOnChange: true)
        // do not forget to add environment variables to your config!
        .AddEnvironmentVariables();
    

提交回复
热议问题