App.config replacements for unit tests

后端 未结 3 1084
终归单人心
终归单人心 2021-02-02 00:38

my continuous integration server (TeamCity) is configured to run all the unit tests in our app on build. Prior to running those tests, i need to change some of the appSettings t

3条回答
  •  长发绾君心
    2021-02-02 01:30

    It's possible to use Web.config Transformations for App.config files through a workaround.

    You simply have to invoke the appropriate MSBuild tasks at the right stage in your build process.
    Add this code snippet to your project file:

    
    
    
        
        
        
        
            
            
                $(TargetFileName).config
            
        
    
    

    Then add additional App.config files to your project for each build configuration where you wish to apply a transformation. For example:

    
        
        
            App.config
        
    
    

    Related resources:

    • Web.config Transformation Syntax for Web Application Project Deployment
    • .Config File Transformation

提交回复
热议问题