For ou application we use a XML File which is generated during build process (at the moment with NAnt). In the XML file is for each application Module a section. Now I want to switch from NAnt to MSBuild.
I want to append for each Module the Module descriptions to our XML File. The XML file should have the following structure
<?xml version="1.0" encoding="utf-8"?>
<FactoryConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Modules>
<ModuleConfig>
<ModuleName>Module1</ModuleName>
<Description>Module1 Description</Description>
<AssemblyName>Assembly.Module1</AssemblyName>
<ModuleClass>Module1.class</ModuleClass>
<Enabled>true</Enabled>
</ModuleConfig>
<ModuleConfig>
<ModuleName>Module2</ModuleName>
<Description>Module2 Description</Description>
<AssemblyName>Assembly.Module2</AssemblyName>
<ModuleClass>Module2.class</ModuleClass>
<Enabled>true</Enabled>
</ModuleConfig>
</Modules>
</FactoryConfig>
Here my MSBuild Code
<XmlPeek XmlInputPath="$(WebDir)FactoryConfig.xml" Query="/FactoryConfig/Modules">
<Output TaskParameter="Result" ItemName="Peeked" />
</XmlPeek>
<Message Text="Subtree: @(Peeked)" />
<XmlPoke XmlInputPath="$(WebDir)FactoryConfig.xml" Query="/FactoryConfig/Modules" Value="@(Peeked)
<ModuleConfig>
<ModuleName>Test</ModuleName>
<Description>Test</Description>
<AssemblyName>Test</AssemblyName>
<ModuleClass>Test</ModuleClass>
<Enabled>true</Enabled>
</ModuleConfig>">
</XmlPoke>
I can add one section to the xml file. But I don't know how to read the existing tree as string and merge it with a new one and add it to the file.
If a Module is already in there it should be replaced.