Transforming included configuration files using configSource

前端 未结 1 734
花落未央
花落未央 2021-02-09 04:27

This question is kind of a two parter. In VS2015 my MVC project has multiple different build configurations, Test, UAT, Live etc. With my web.config I can simply ri

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 05:12

    I opted for the solution of using a base Log4Net.config file, a Log4Net.XXX.config file for each build configuration and an additional TransformXml task in the AfterBuild target :

    • Log4Net.config
    • Log4Net.Debug.config
    • Log4Net.Release.config
    • Log4Net.Test.config
    • Log4Net.UAT.config

    The project.csproj file now looks like this :

    
      Always
    
    
      Log4Net.config
    
    
      Log4Net.config
    
    
      Log4Net.config
    
    
      Log4Net.config
    
    
    ....
    
    
       
       
    
    

    And an example Log4Net.Test.config looks like this (I am using the transform to change connection strings and Log4Net's logging level) :

    
    
    
        
            
        
    
        
            
        
    
    

    This transforms the Log4Net.config file in the output path successfully. It uses the same approach as transforming web.config files and so should be easily understandable by any other developer that picks up the project.

    Whilst this works and has been in production for a while now, I'm still looking for some confirmation that this is the correct way of doing transforms of included config files.

    0 讨论(0)
提交回复
热议问题