문제 설명
MSDeploy를 사용하여 Web.config 사용자 지정 섹션을 변환하는 방법은 무엇입니까? (How‑to Transform Web.config Custom Sections With MSDeploy?)
MSDeploy를 사용할 때 web.config 사용자 정의 섹션 값을 변환하는 방법이 있습니까?
<configSections>
<sectionGroup name="myGroup">
<section name="data" type="MyApp.DataConfigurationSection, MyApp.Data" />
</sectionGroup>
</configSections>
<myGroup>
<data interval="3" useCache="true" />
</myGroup>
빌드 구성에 따르면 "useCache" 값을 변경하는 예가 필요합니다.
참조 솔루션
방법 1:
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>
방법 2:
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.