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

后端 未结 12 2435
刺人心
刺人心 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条回答
  •  伪装坚强ぢ
    2020-12-04 15:57

    In my case I have several appSettings files for several live environments, e.g. appSettings.Env1Live.json, appSettings.Env2Live.json, etc.

    I looked through the article https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/visual-studio-publish-profiles?view=aspnetcore-3.1 and added the following statements in the corresponding publish (pubxml) config files per each environment.

    E.g. for PublishToEnvironment1.pubxml added:

    
    
    
    
    

    So, in the published folder I have only two necessary files, other appSettings.*Live.json were not published.

    appsettings.json

    appsettings.Env1Live.json

提交回复
热议问题