我正在使用web.config转换,如下面的帖子所述,以便为不同的环境生成配置。有没有办法使用web.config转换来执行“替换或插入”?
http://vishaljoshi.blogspot.com/2009/03/web-deployment-webconfig-transformation_23.html
我可以通过在关键的匹配做一个“替换”改造,例如
<add key="Environment" value="Live" xdt:Transform="Replace" xdt:Locator="Match(key)" />
我可以做“Inserts”例如
<add key="UseLivePaymentService" value="true" xdt:Transform="Insert" />
但我会真的找到有用的是ReplaceOrInsert转型,因为我不能总是依赖于具有/不具有某些关键的原始配置文件。
有没有办法做到这一点?
如果使用VS2012,现在有更好的解决方案。见下面http://stackoverflow.com/a/16679201/32055 – 2013-05-22 09:37:45
将“InsertIfMissing”插入和替换如果需要? – Jessycormier 2014-02-12 14:15:59