I am trying to add a new version element before all the existing version elements.
<XmlFile TaskAction="AddElement" Element="version" XPath="//database" InsertBeforeXPath="//database/version[1]" File="$(DBVersionsPath)"/>
Adds a new version element after the existing version element and ignores the InsertBeforeXPath.
I also tried
<XmlFile TaskAction="AddElement" Element="version" ParentElement="//database" InsertBeforeXPath="//database/version[1]" File="$(DBVersionsPath)"/>
but found there is a previously documented issue that you cannot add a duplicate Element unless you specify an XPath.
I can see how to work around either bug individually but not both combined.
-edit-
Solved my problem with
<XmlFile TaskAction="AddElement" Element="version" ParentElement="//db:database" InsertBeforeXPath="//db:database/db:version[1]" File="$(DBVersionsPath)" Namespaces="@(Namespaces)"/>
Was testing against a simplified version of the real xml, which didn't require Namespaces to be specified.
Comments: solved by user :-)
<XmlFile TaskAction="AddElement" Element="version" XPath="//database" InsertBeforeXPath="//database/version[1]" File="$(DBVersionsPath)"/>
Adds a new version element after the existing version element and ignores the InsertBeforeXPath.
I also tried
<XmlFile TaskAction="AddElement" Element="version" ParentElement="//database" InsertBeforeXPath="//database/version[1]" File="$(DBVersionsPath)"/>
but found there is a previously documented issue that you cannot add a duplicate Element unless you specify an XPath.
I can see how to work around either bug individually but not both combined.
-edit-
Solved my problem with
<XmlFile TaskAction="AddElement" Element="version" ParentElement="//db:database" InsertBeforeXPath="//db:database/db:version[1]" File="$(DBVersionsPath)" Namespaces="@(Namespaces)"/>
Was testing against a simplified version of the real xml, which didn't require Namespaces to be specified.
Comments: solved by user :-)