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

前端 未结 4 799
被撕碎了的回忆
被撕碎了的回忆 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:32

    Use the InsertIfMissing transformation to ensure that the appSetting exists.
    Then use the Replace transformation to set its value.

    
      
      
    
    

    You could also use the SetAttributes transformation instead of Replace. The difference is that SetAttributes does not touch child nodes.

      
      
      
    
    

    These techniques are much better than remove+insert because existing nodes are not moved to the bottom of their parent node. New nodes are appended at the end. Existing nodes stay where they are in the source file.

    This answer applies only to newer versions of Visual Studio (2012 or newer).

提交回复
热议问题