web.config XML-Document-Transform not working in VS 2013

601 views Asked by At

To automate the web.config transformation for different environments whats the best concept to use ? I have below one as one of the option to do this. But are there any better options than this SDT ?

I tried to use XML-Document-Transform concept to generate the config files for the environments like Test,Staging and PROD. But the resultant web.config doesn't reflect the changes of Test/Staging/RPOD.

web.config xml:

 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
    <connectionStrings>
        <add name="personalDB"
              connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyDevReleaseDB;Integrated Security=True" />
   </connectionStrings>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
   </system.web>
  <system.webServer>
     <defaultDocument>
       <files>
         <add value="lists.html" />
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>

And the below one is Web.PROD.config with xdt keywords which was showing in the active solution configuration in configuration manager.

 <?xml version="1.0" encoding="utf-8"?>               
 <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">      
     <connectionStrings>
       <add name="personalDB" 
         connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleasePRODDB;Integrated Security=True" 
         xdt:Transform="Replace" xdt:Locator="Match(name)"/>
   </connectionStrings>
   <system.web>
      <compilation xdt:Transform="RemoveAttributes(debug)" />
   </system.web>
 </configuration>

What am I doing wrong here ?

1

There are 1 answers

0
krrishna On BEST ANSWER

I was trying to build the solution and verifying the web.config which is not the right way to check the transformed web.config.

When i deployed the Web application by using the selected build configuration and by using one-click publish to local host on local iis, the Web.config file is transformed .