How do you manage .NET app.config files for large applications?

后端 未结 5 2219
無奈伤痛
無奈伤痛 2020-12-04 22:26

Suppose a large composite application built on several foundation components packaged in their own assemblies: (database reading, protocol handlers, etc.). For some deploy

5条回答
  •  清歌不尽
    2020-12-04 23:12

    My preferred method is to use MSBuild, if you right click on a project and click 'unload' a new menu option will pop up that says 'edit '. Select that and it'll open up the project file so you can edit it, scroll down until you find a commented out section that is called "AfterBuild".

    You can then add something like:

    
        
        
    
    

    This will replace the application config with one named [Release|Debug]app.exe.config. So you can maintain separate configurations depending on how the project is built.

    But a quick and dirty option (if you don't want to play with msbuild) is to just maintain separate config files and then define which one you want to include, like this:

    
    
    

    And if you are doing an asp.net application, microsoft provides a great utility called "Web Deployment Projects" that will allow you to manage all of this easily, click here

提交回复
热议问题