XDT 변환을 사용하여 내 NuGet 패키지 용 web.config 설치 프로그램을 만들려고합니다.대상 구성 파일의 구조를 모르는 경우 깊은 XDT 변환을 처리하는 방법은 무엇입니까?
내가 web.config 파일 변환하려면 :
<configuration>
<system.web>
</system.web>
</configuration>
는 다음과 같이하기 :
하는 # 변환 : 여기
<configuration>
<system.web>
<httpHandlers>
<add path="*." verb="*" type="CustomHandler" />
</httpHandlers>
</system.web>
</configuration>
내가 시도했던 변환됩니다 1 :
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<httpHandlers>
<add path="*." verb="*" type="CustomHandler" xdt:Transform="Insert" />
</httpHandlers>
</system.web>
</configuration>
대상 web.config에 이미 <httpHandlers />
섹션이있는 경우에만 작동합니다.
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<httpHandlers xdt:Transform="Insert">
<add path="*." verb="*" type="CustomHandler" />
</httpHandlers>
</system.web>
</configuration>
이 상기 예상 작동으로 :
No element in the source document matches '/configuration/system.web/httpHandlers/add'
가 2 변형 : 위 예에서
이 결과 오류 (참고 더<httpHandlers />
부 없음) 위의 예에서 이미 존재하지만 <httpHandlers />
섹션이있는 web.config 파일이 있으면 해당 섹션이 복제됩니다. 이것은 NuGet 패키지를위한 것이며 사용자의 구성 상태에 대한 가정을 할 수 없음을 기억하십시오.
저는 XDT Transforms를 처음 사용 했으므로 확실하지 않은 것을 놓쳤을 수 있습니다.
굉장! 고마워, 닐. –
슬프게도 해당하는 xdt : Transform = "RemoveIfEmpty"가 없으므로 반대가됩니다. –
글쎄, 그들은 오픈 소스를 했어 ... 너 자신을 쓸 수있어! http://xdt.codeplex.com/ – NeilD