gpt4 book ai didi

msbuild - XmlMassUpdate - 替换值节点

转载 作者:行者123 更新时间:2023-12-02 11:21:33 25 4
gpt4 key购买 nike

我正在尝试使用 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>

我正在尝试更新此文件中的 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>

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

我将如何替换值节点?

问候

特瑞斯

最佳答案

以下脚本对我来说工作正常(在 1.3.0.471 上运行,这可能是每晚构建):

构建.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>

输入.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(由构建生成)

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

关于msbuild - XmlMassUpdate - 替换值节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1294438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com