4

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.

This is the config section:

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

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>

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

How would i go about replacing the value node?

Regards

Tris

Chris Chilvers
  • 6,429
  • 3
  • 32
  • 53

1 Answers1

6

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

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

<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 (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>
Chris Chilvers
  • 6,429
  • 3
  • 32
  • 53
  • 1
    I appear to have version 1.2.0.306 - can't find 1.3 anywhere. –  Aug 18 '09 at 15:37
  • I have run the files you have supplied and the current build i have does not replace the value nodes contents. Where can i find the 1.3 build? It does not appear to be hosted on the community tasks site. –  Aug 18 '09 at 15:48
  • Got it. Thankyou. I've spent the whole day trying to figure out what was wrong with my script :( –  Aug 18 '09 at 16:04
  • Had the same problem. Version 1.2.0.306 would not update the value tag, but it all works after updating to the latest nightly (1.3.0.477). – eyesnz Sep 21 '09 at 00:04
  • How would you add multiple value nodes? 1 2 – Derek Hunziker Feb 18 '11 at 01:45