有没有什么办法做了"更换或插入"使用的web.config转型? [英] Is there any way to do a "Replace Or Insert" using web.config transformation?
问题描述
我使用的web.config变换为以产生用于不同环境的configs在后下描述
I'm using web.config transformation as described in the below post in order to generate configs for different environments.
<一个href=\"http://vishaljoshi.blogspot.com/2009/03/web-deployment-webconfig-transformation_23.html\">http://vishaljoshi.blogspot.com/2009/03/web-deployment-webconfig-transformation_23.html
我可以通过在关键的,例如匹配做一个替换的转变。</ P>
I can do a "Replace" transformation by matching on the key, e.g.
<add key="Environment" value="Live" xdt:Transform="Replace" xdt:Locator="Match(key)" />
和我能做的插入例如。
<add key="UseLivePaymentService" value="true" xdt:Transform="Insert" />
但我的真正的找到有用的是ReplaceOrInsert转型,因为我不能总是依靠具有/不具有某些关键原配置文件。
But what I would really find useful is a ReplaceOrInsert transformation, as I can't always rely on the original config file having/not having a certain key.
有没有办法做到这一点?
Is there any way to do this?
推荐答案
我发现了一个廉价的解决方法。它不是pretty,如果你有很多的元素需要被替换或插入将不能很好地工作。
I found a cheap workaround. It ain't pretty and won't work very well if you have a lot of elements that needs to be "Replace Or Insert".
做一个删除,然后在InsertAfter |的insertBefore
Do a "Remove" and then an "InsertAfter|InsertBefore".
例如,
<authorization xdt:Transform="Remove" />
<authorization xdt:Transform="InsertAfter(/configuration/system.web/authentication)">
<deny users="?"/>
<allow users="*"/>
</authorization>
这篇关于有没有什么办法做了&QUOT;更换或插入&QUOT;使用的web.config转型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!