title: Advanced tasks using Web.Config transformation
body: <p>Does anyone know if there is a way to &quot;transform&quot; specific sections of values instead of replacing the whole value or an attribute?</p>
  <p>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</p>
  <pre><code>&lt;!-- DEV ENTRY --&gt;
  &lt;appSettings&gt;
   &lt;add key=&quot;serviceName1_WebsService_Url&quot; value=&quot;http://wsServiceName1.dev.example.com/v1.2.3.4/entryPoint.asmx&quot; /&gt;
   &lt;add key=&quot;serviceName2_WebsService_Url&quot; value=&quot;http://ma1-lab.lab1.example.com/v1.2.3.4/entryPoint.asmx&quot; /&gt;
  &lt;/appSettings&gt;
  
  &lt;!-- PROD ENTRY --&gt;
  &lt;appSettings&gt;
   &lt;add key=&quot;serviceName1_WebsService_Url&quot; value=&quot;http://wsServiceName1.prod.example.com/v1.2.3.4/entryPoint.asmx&quot; /&gt;
   &lt;add key=&quot;serviceName2_WebsService_Url&quot; value=&quot;http://ws.ServiceName2.example.com/v1.2.3.4/entryPoint.asmx&quot; /&gt;
  &lt;/appSettings&gt;
  </code></pre>
  <p>Notice that on the fist entry, the only difference is <strong>&quot;.dev&quot; from &quot;.prod&quot;.</strong> On the second entry, the subdomain is different: <strong>&quot;ma1-lab.lab1&quot;</strong> from <strong>&quot;ws.ServiceName2&quot;</strong></p>
  <p>So far, I know I can do something like this in the <code>Web.Release.Config</code>:</p>
  <pre><code>&lt;add xdt:Locator=&quot;Match(key)&quot; xdt:Transform=&quot;SetAttributes(value)&quot; key=&quot;serviceName1_WebsService_Url&quot; value=&quot;http://wsServiceName1.prod.example.com/v1.2.3.4/entryPoint.asmx&quot; /&gt;
  &lt;add xdt:Locator=&quot;Match(key)&quot; xdt:Transform=&quot;SetAttributes(value)&quot; key=&quot;serviceName2_WebsService_Url&quot; value=&quot;http://ws.ServiceName2.example.com/v1.2.3.4/entryPoint.asmx&quot; /&gt;
  </code></pre>
  <p>However, every time the Version for that webservice is updated, I would have to update the <code>Web.Release.Config</code> as well, which defeats the purpose of simplfying my <code>web.config</code> updates.</p>
  <p>I know I could also split that URL into different sections and update them independently, but I rather have it all in one key.</p>
  <p>I've looked through the available <code>web.config</code> Transforms but nothings seems to be geared towars what I am trying to accomplish.</p>
  <p>These are the websites I am using as a reference:</p>
  <p><a href="http://vishaljoshi.blogspot.com/2009/03/web-deployment-webconfig-transformation_23.html" rel="nofollow noreferrer">Vishal Joshi's blog</a>, <a href="http://msdn.microsoft.com/en-us/library/dd465326(VS.100).aspx" rel="nofollow noreferrer">MSDN Help</a>, and <a href="http://channel9.msdn.com/shows/10-4/10-4-Episode-10-Making-Web-Deployment-Easier/" rel="nofollow noreferrer">Channel9 video</a></p>