2009-09-18 11 views
5

Ich wollte eine kurze Frage zum Verhalten der MSBuild-Task XmlMassUpdate stellen.MSBuild XmlMassUpdate Task

Hat jemand gefunden, dass die Aufgabe nur eindeutige Knoten in den XML-Inhalt kopieren wird? Wenn ich zum Beispiel einen Client-Knoten habe, der mehrere untergeordnete Knoten hat, der als Endpunkt bezeichnet wird, kopiert er nur den ersten Endpunktknoten in Masse, während er alle anderen eliminiert.

Ich habe unten einige Beispiele zur Verfügung gestellt, vielen Dank im Voraus. MSBuild Aufgabe

:

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

Inhalt:

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

Ersatz:

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

Ausgang:

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

Antwort

6

Der XmlMassUpdate Hilfe-Bereich in der MSBuildCommunityTasks Hilfedatei zeigt Beispiele mit mehreren Elementen zu tun, die den gleichen Namen haben.

Sie müssen die Elemente mithilfe eines eindeutigen Attributs unterscheiden. Dieses Attribut wird als XmlMassUpdate- "Schlüssel" definiert. In Ihrem Fall funktioniert das Namensattribut. Ich glaube, dass dieser aktualisierte Ersetzungscode Ihr Problem beheben wird, beachten Sie die xmu-Attribute.

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