Does anyone know if there is a way to "transform" specific sections of values instead of replacing the whole value or an attribute?
For example, I've got several appSettings entries that specify the Urls for different webservices. These entries are slightly different in the dev environment than the production environment. Some are less trivial than others
<!-- DEV ENTRY -->
<appSettings>
<add key="serviceName1_WebsService_Url" value="http://wsServiceName1.dev.domain.com/v1.2.3.4/entryPoint.asmx" />
<add key="serviceName2_WebsService_Url" value="http://ma1-lab.lab1.domain.com/v1.2.3.4/entryPoint.asmx" />
</appSettings>
<!-- PROD ENTRY -->
<appSettings>
<add key="serviceName1_WebsService_Url" value="http://wsServiceName1.prod.domain.com/v1.2.3.4/entryPoint.asmx" />
<add key="serviceName2_WebsService_Url" value="http://ws.ServiceName2.domain.com/v1.2.3.4/entryPoint.asmx" />
</appSettings>
Notice that on the fist entry, the only difference is ".dev" from ".prod". On the second entry, the subdomain is different: "ma1-lab.lab1" from "ws.ServiceName2"
So far, I know I can do something like this in the Web.Release.Config:
<add xdt:Locator="Match(key)" xdt:Transform="SetAttributes(value)" key="serviceName1_WebsService_Url" value="http://wsServiceName1.prod.domain.com/v1.2.3.4/entryPoint.asmx" />
<add xdt:Locator="Match(key)" xdt:Transform="SetAttributes(value)" key="serviceName2_WebsService_Url" value="http://ws.ServiceName2.domain.com/v1.2.3.4/entryPoint.asmx" />
However, everytime the Version for that webservice is updated, I would have to update the Web.Release.Config as well, which defeats the purpose of simplfying my web.config updates.
I know I could also split that URL into different sections and update them independently, but I rather have it all in one key.
I've looked through the available web.config Transforms but nothings seems to be geared towars what I am trying to accomplish.
These are the websites I am using as a reference:
Vishal Joshi's blog, MSDN Help, and Channel9 video
Any help would be much appreciated!
-D
See Question&Answers more detail:os