How to use different .settings files for different environments in .NET?

前端 未结 6 794
温柔的废话
温柔的废话 2021-02-02 01:11

.NET allows you to use .settings files to manage application settings. I would like to store Production, Development and Test settings separately in a way that I can do somethi

6条回答
  •  感情败类
    2021-02-02 02:01

    I currently do something similar to the solution mentioned by pdavis. But to simplifying multiple config files I use a T4 templates to create the environment specific config files. That way there is one web.tt file that handles the generation of the default web.config file. Each environment has its own template file (qa.tt, production.tt, etc) that inherits from web.tt and contains any environment specific overrides. Any changes to web config - new app settings, configuration settings, etc. are automatically propagated to all region specific config files by regenerating the templates, and you don't have to worry about keeping files in sync using a diff tool.

提交回复
热议问题