标签: xmlmassupdate

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>
Run Code Online (Sandbox Code Playgroud)

内容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.servicemodel/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

替换:

<?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>
Run Code Online (Sandbox Code Playgroud)

输出:

<?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>
Run Code Online (Sandbox Code Playgroud)

msbuild xmlmassupdate

5
推荐指数
1
解决办法
2496
查看次数

XmlMassUpdate - 替换值节点

我正在尝试使用XmlMassUpdate根据构建版本类型更新我的配置文件.似乎没有关于如何在任何地方更新新的app.config(vs2008)设置格式的文档.

这是配置部分:

<applicationSettings>
<CTC.Mica.ClientService.Properties.Settings>
  <setting name="PipeName" serializeAs="String">
    <value>\\.\pipe\micaPipe</value>
  </setting>
  <setting name="CTC_Mica_ClientService_MicaWebService_MicaWebService"
      serializeAs="String">
    <value>URL</value>
  </setting>
</CTC.Mica.ClientService.Properties.Settings>
</applicationSettings>
Run Code Online (Sandbox Code Playgroud)

我正在尝试更新此文件中的URL值:

<Debug>
    <setting xmu:key="name" name="CTC_Mica_ClientService_MicaWebService_MicaWebService" serializeAs="String">
      <value>DEVURL</value>
    </setting>
</Debug>

<Test>
    <setting xmu:key="name" name="CTC_Mica_ClientService_MicaWebService_MicaWebService" serializeAs="String">
      <value>TESTURL</value>
    </setting>
</Test>

<Release>
    <setting xmu:key="name" name="CTC_Mica_ClientService_MicaWebService_MicaWebService" serializeAs="String">
      <value>LIVEURL</value>
    </setting>
</Release>
Run Code Online (Sandbox Code Playgroud)

运行脚本,我可以替换"name"或"serializeAs"属性,但不能替换值节点.

我将如何更换价值节点?

问候

msbuild app-config xmlmassupdate

4
推荐指数
1
解决办法
3341
查看次数

XmlMassUpdate - 如何删除节点

我们想使用msbuild从web.config文件中清除connectionStrings部分.

最简单的方法是什么?

我们以前使用过XmlMassUpdate来替换值(另请参阅此问题:XmlMassUpdate - 替换值节点),但还没有找到完全删除它的方法.

更多细节:

我们想要更改web.config中的部分

<connectionStrings>
  <add name="connectionString1" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=Db1;Integrated Security=True" />
</connectionStrings>

<connectionStrings>
</connectionStrings>

msbuild web-config xmlmassupdate

4
推荐指数
1
解决办法
1619
查看次数

标签 统计

msbuild ×3

xmlmassupdate ×3

app-config ×1

web-config ×1