首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MSBuild XmlMassUpdate任务

MSBuild XmlMassUpdate任务
EN

Stack Overflow用户
提问于 2009-09-18 12:50:40
回答 1查看 2.6K关注 0票数 5

我想问一个关于MSBuild任务XmlMassUpdate的行为的快速问题。

有人发现任务只会将唯一的节点复制到内容XML中吗?例如,如果我有一个具有多个名为终结点的子节点的客户端节点,那么它只会大量复制第一个端点节点,同时消除所有其他节点。

下面我已经给出了我所描述的一些例子,非常感谢。

MSBuild任务:

代码语言:javascript
复制
<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>

内容:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.servicemodel/>
</configuration>

替换:

代码语言:javascript
复制
<?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>

输出:

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

发布于 2009-12-23 17:18:13

包含在XmlMassUpdate帮助文件中的MSBuildCommunityTasks帮助部分展示了处理具有相同名称的多个元素的示例。

您需要使用唯一属性来区分元素,该属性将被定义为XmlMassUpdate "key“。在您的例子中,name属性将起作用。我相信下面更新的替换代码将修复您的问题,注意xmu属性。

代码语言:javascript
复制
<?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>
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1444366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档