我正在使用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