开发者

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>

  <myGr开发者_如何学Gooup>
    <data interval="3" useCache="true" />
  </myGroup>

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


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>


Yes, MSDeploy supports this quite easily.

When you create a deployment package you want to use the -declareParm option to create a replaceable parameter in your deployment package. You'd use something like:

-declareParam:name=UseCache,kind=XmlFile,scope=web.config,match="/configuration/myGroup/data/@useCache"

Then when deploying your package, you'd use the -setParm command to replace the parameter during deployment. Something like:

-setParam:name=UseCache,value="false"

This example would replace the UseCache parameter, which points to the useCache attribute in the web.config file with "false".

You can declare any number of parameters to be replaced and MSDeploy supports using files to hold the parameters. Files are simple Xml files you would then use the -setParamFile:<filename> and -declareParamFile:<filename> syntax.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜