MSBuild XmlMassUpdate Task
Я хотел задать быстрый вопрос о поведении задачи 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>
1 ответ
Раздел справки 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>