2009-09-18 11 views
5

MSBuildタスクXmlMassUpdateの動作について簡単に質問したいと思います。MSBuild XmlMassUpdateタスク

タスクはコンテンツXMLに固有のノードのみをコピーすることに誰も気付いていませんか?たとえば、エンドポイントと呼ばれる複数の子を持つクライアント・ノードがある場合、最初のエンドポイント・ノードのみをマス・コピーし、それ以外はすべて除去します。

ここでは、私が説明していることのいくつかの例を提供しました。

の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> 
関連する問題