2009-09-18 4 views
5

MSBuild 작업 XmlMassUpdate의 동작에 대해 빠른 질문을하고 싶습니다.MSBuild XmlMassUpdate 작업

누구나 작업을 통해 고유 노드를 콘텐츠 XML에만 복사한다는 사실을 알고 있습니까? 예를 들어, endpoint라는 여러 개의 하위가있는 클라이언트 노드가있는 경우, 다른 모든 노드를 제거하면서 첫 번째 엔드 포인트 노드 만 복사합니다.

아래에 몇 가지 예가 나와 있습니다. 사전에 많은 감사의 말을 전합니다.

은 MSBuild 작업 :

<Project DefaultTargets="Run" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.targets" /> 
    <Target Name="Run"> 
     <Delete Condition="Exists('web.config')" Files="web.config"/> 
     <XmlMassUpdate 
      ContentFile="app.config" 
      ContentRoot="configuration/system.servicemodel" 
      SubstitutionsFile="wcf.config" 
      SubstitutionsRoot="/system.servicemodel" 
      MergedFile="web.config" 
      /> 
    </Target> 
</Project> 

내용 :

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.servicemodel/> 
</configuration> 

교체 :

<?xml version="1.0" encoding="utf-8" ?> 
<system.servicemodel> 
    <client> 
     <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_LargeMessage" 
        contract="ClaimsService.IClaimsService" 
        name="WSHttpBinding_IClaimsService"> 
     </endpoint> 
     <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_LargeMessage" 
        contract="LateCertificationAdminService.ILateCertificationAdminService" 
        name="WSHttpBinding_ILateCertificationAdminService"> 
     </endpoint> 
    </client> 
</system.servicemodel> 

출력 :

<?xml version="1.0" encoding="utf-8" ?> 
<system.servicemodel> 
    <client> 
     <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_LargeMessage" 
        contract="ClaimsService.IClaimsService" 
        name="WSHttpBinding_IClaimsService"> 
     </endpoint> 
    </client> 
</system.servicemodel> 

답변

6

XmlMassUpdate 도움말 섹션은 MSBuildCommunityTasks 도움말 파일에 포함 된 동일한 이름을 가진 복수의 요소를 처리하는 예를 보여줍니다.

고유 한 특성을 사용하여 요소를 구분해야하며이 특성은 XmlMassUpdate "키"로 정의됩니다. 귀하의 경우 name 속성이 작동합니다. 아래의 업데이트 된 대체 코드가 문제를 해결하고 xmu 속성을 확인합니다.

<?xml version="1.0" encoding="utf-8" ?> 
<system.servicemodel> 
    <client xmlns:xmu="urn:msbuildcommunitytasks-xmlmassupdate"> 
     <endpoint xmu:key="name" 
        binding="wsHttpBinding" 
        bindingConfiguration="WSHttpBinding_LargeMessage" 
        contract="ClaimsService.IClaimsService" 
        name="WSHttpBinding_IClaimsService"> 
     </endpoint> 
     <endpoint xmu:key="name" 
        binding="wsHttpBinding" 
        bindingConfiguration="WSHttpBinding_LargeMessage" 
        contract="LateCertificationAdminService.ILateCertificationAdminService" 
        name="WSHttpBinding_ILateCertificationAdminService"> 
     </endpoint> 
    </client> 
</system.servicemodel> 
관련 문제