Is there any way to do a “Replace Or Insert” using web.config transformation?

前端 未结 4 808
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 17:28

I\'m using web.config transformation as described in the below post in order to generate configs for different environments.

http://vishaljoshi.blogspot.com/2009/03/

4条回答
  •  长情又很酷
    2020-12-22 18:33

    A better method for me was to insert the element only if it doesn't exist since I am only setting certain attributes. Removing the element would discard any other attributes of the main element if they existed.

    example: web.config (without element)

    
        
            
        
    
    

    web.config (with element)

    
        
            
            
        
    
    

    Using the Locator with an XPath expression, I add the node if it doesn't exist and then set my attribute:

    
    
    

    both resulting web.config files have includeExceptionDetailInFaults="true" and the second one preserves the httpsHelpPageEnabled attribute where the remove/insert method would not.

提交回复
热议问题