2009-09-18 17 views
5

Chciałem zadać szybkie pytanie dotyczące zachowania zadania MSBuild XmlMassUpdate.MSBuild XmlMassUpdate Zadanie

Ktoś odkrył, że zadanie skopiuje tylko unikalne węzły do ​​zawartości XML? Na przykład, jeśli mam węzeł kliencki, który ma wiele obiektów podrzędnych nazywanych punktami końcowymi, to tylko masowo skopiuje pierwszy węzeł punktu końcowego, eliminując wszystkie pozostałe.

Podałem kilka przykładów poniżej tego, co opisuję, z góry dziękuję.

MSBuild Zadanie:

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

Treść:

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

Zamiennik:

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

wyjściowa:

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

Odpowiedz

6

sekcji pomocy XmlMassUpdate zawarte w pliku MSBuildCommunityTasks pomocy pokazuje przykłady radzenia sobie z wieloma elementami, które mają taką samą nazwę.

Musisz rozróżnić elementy za pomocą unikalnego atrybutu, ten atrybut zostanie zdefiniowany jako "klucz" XmlMassUpdate. W twoim przypadku atrybut nazwy zadziała. Uważam, że ten zaktualizowany kod zastępczy poprawi Twój problem, zwróć uwagę na atrybuty 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> 
Powiązane problemy