Quantcast
Channel: MSBuild Extension Pack
Viewing all articles
Browse latest Browse all 1211

New Post: XMLFile Addelement - need to add 3 elements of same type but fails on 2nd?

$
0
0

You need to use Xpath. If you use addelement without an xpath then you can't add the same element more than once. This isn't too well documented. This should work for you

 

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>
    <ItemGroup>
        <Itemgroup Include="1">
            <ID>RE1</ID>
        </Itemgroup>
        <Itemgroup Include="2">
            <ID>RE2</ID>
        </Itemgroup>
        <Itemgroup Include="3">
            <ID>RE3</ID>
        </Itemgroup>
    </ItemGroup>
    <Target Name="Default">
        <XmlFile TaskAction="AddElement" File="d:\a\pathtoxmlfile.xml" Element="RenderEngine" ParentElement="//RenderingConfiguration/RenderEngines" XPath="//RenderingConfiguration/RenderEngines" Key="ID" Value="%(Itemgroup.ID)" />
    </Target>
</Project>

Viewing all articles
Browse latest Browse all 1211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>