XmlMassUpdate-替换值节点 [英] XmlMassUpdate - Replace Value Node

查看:76
本文介绍了XmlMassUpdate-替换值节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use XmlMassUpdate to update my config files based on build Version type. There seems to be no documentation on how to update the new app.config (vs2008) settings formats anywhere.

这是配置部分:

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

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

And i am trying to update the URL value from this file:

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

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

Running the script, i can replace either the "name" or the "serializeAs" attributes, but not the value node.

我将如何替换值节点?

致谢

Tris

推荐答案

以下脚本对我来说很好(在1.3.0.471上运行,这可能是每晚构建的):

The following scripts work fine for me (running on 1.3.0.471 which might be a nightly build):

build.proj

build.proj

<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('output.xml')" Files="output.xml"/>
        <XmlMassUpdate 
            ContentFile="input.xml"
            ContentRoot="/test"
            SubstitutionsFile="subs.xml"
            SubstitutionsRoot="/substitutions/release"
            MergedFile="output.xml"
            />
    </Target>
</Project>

input.xml

input.xml

<test>
  <setting name="PipeName" serializeAs="String">
    <value>\\.\pipe\micaPipe</value>
  </setting>
  <setting name="CTC_Mica_ClientService_MicaWebService_MicaWebService" serializeAs="String">
    <value>URL</value>
  </setting>
</test>

subs.xml

<substitutions xmlns:xmu="urn:msbuildcommunitytasks-xmlmassupdate">
    <release>
        <setting xmu:key="name" name="CTC_Mica_ClientService_MicaWebService_MicaWebService" serializeAs="Testing">
            <value>LIVEURL</value>
        </setting>
    </release>
</substitutions>

output.xml(由内部生成)

output.xml (generated by build)

<test>
  <setting name="PipeName" serializeAs="String">
    <value>\\.\pipe\micaPipe</value>
  </setting>
  <setting name="CTC_Mica_ClientService_MicaWebService_MicaWebService" serializeAs="Testing">
    <value>LIVEURL</value>
  </setting>
</test>

这篇关于XmlMassUpdate-替换值节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆