2009-09-18 17 views
5

Volevo porre una breve domanda sul comportamento dell'attività XmlMassUpdate di MSBuild.MSBuild XmlMassUpdate Task

Qualcuno ha rilevato che l'attività copierà solo nodi univoci sul contenuto XML? Ad esempio, se ho un nodo client che ha più figli chiamati endpoint, quindi copierà in massa il primo nodo endpoint eliminando tutti gli altri.

Ho fornito alcuni esempi sotto di ciò che sto descrivendo, molte grazie in anticipo.

MSBuild Task:

<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> 

Content:

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

sostituzione:

<?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> 

uscita:

<?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> 

risposta

6

La sezione di aiuto XmlMassUpdate incluso nel file di aiuto MSBuildCommunityTasks mostra esempi di affrontare con più elementi che hanno lo stesso nome.

È necessario differenziare gli elementi utilizzando un attributo univoco, questo attributo sarà definito come "chiave" XmlMassUpdate. Nel tuo caso, l'attributo name funzionerà. Credo che questo codice di sostituzione aggiornato di seguito risolverà il problema, noterai gli attributi 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>