Search code examples
msbuildmsdeploy

How-to Transform Web.config Custom Sections With MSDeploy?


Is there any way to transform web.config custom sections values when using MSDeploy ?

  <configSections>
    <sectionGroup name="myGroup">
      <section name="data" type="MyApp.DataConfigurationSection, MyApp.Data" />
    </sectionGroup>
  </configSections>

  <myGroup>
    <data interval="3" useCache="true" />
  </myGroup>

According to build configuration i need for exemple to change "useCache" value.


Solution

  • Write transformation in config transformation file (web.config.release)

    <?xml version="1.0"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <myGroup>
        <data useCache="false" xdt:Transform="SetAttributes(useCache)" />
      </myGroup>
    </configuration>