views:

793

answers:

1

Hi Guys. 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

+1  A: 

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"&gt;
    <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>
KeeperOfTheSoul
I appear to have version 1.2.0.306 - can't find 1.3 anywhere.
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.
http://msbuildtasks.tigris.org/ at the bottom is the latest nightly build.
KeeperOfTheSoul
Got it. Thankyou. I've spent the whole day trying to figure out what was wrong with my script :(
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