Search code examples
visual-studio-2010web-configweb-config-transform

Transformation of web.config


I work on a big asp.net entity framework web application with a lot of EDMX (actually 10, later, more than 30). Each EDMX has his own connection string. When I deploy, my app, I want to change these connection strings. I can replace them with

xdt:Transform="Replace"

But that I need is to replace only a part of the attribut "connectionString".

If my connection string is :

      <add name="DemosEntities" connectionString="metadata=res://*/Demos.csdl|res://*/Demos.ssdl|res://*/Demos.msl;provider=Devart.Data.Oracle;provider connection string=&quot;User Id=user;Password=password;Home=OraClient11g_home1;Data Source=VDN131DEV15;Persist Security Info=True;ClientId=CLOEE2&quot;" providerName="System.Data.EntityClient" />

I just want to replace VDN131DEV15 with another string on all my connection strings.

Possible with web.config transformation ?

Thank you


Solution

  • There is no Transform operation defined that will allow you to replace a part of the attribute value rather than the whole value.

    I think you would need to write a custom build task to apply an xslt to the file in order to do what you want.