MSBuild: How to update xml by xpath

282 views Asked by At

I am trying to find a solution, how can I update release notes in the nuspec xml using MSBuild script.

Now I have create MSBuild target with XmlUpdate:

<XmlUpdate  Prefix="n"
    Namespace="$(Namespace)"
    XmlFileName="%(Files.Name)"
    Xpath="/n:package/n:metadata/n:releaseNotes"
    Value="$(ReleaseNote)"/>

This works fine, but only in case Nuspec file already contains entry.

How can I proceed with files, where releaseNotes is not present at all? Can I somehow get number from xpath, and if it is zero, use another function for xml update?

P.S.: NuGetPack extension from MSBuildTasks does not work with package metagata.

1

There are 1 answers

0
Alex On

Since nothing found, implemented custom MSBuild task according to Microsoft Task Writing reference