Use XmlPoke to replace Xml node
My goal was to update the project file (.proj) of a Visual Studio 2008 project in NAnt script. At first I thought it was a simple task, and I found all the knowledge I need to learn and figure out the proper XPath to find the path I need to modify:
/Project//PostBuildEvent
However, I couldn't get the script XmlPoke running. After a while, I realize that the code WILL run if I take out the name space reference in the project file:
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
I looked into Nant's manual, and found out how to specify namespace entry. But I have problem figuring out what namespace prefix I should use.
Finally I came across this post, which gave me the exact way to write it. So here it goes:
/Project//PostBuildEvent
However, I couldn't get the script XmlPoke running. After a while, I realize that the code WILL run if I take out the name space reference in the project file:
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
I looked into Nant's manual, and found out how to specify namespace entry. But I have problem figuring out what namespace prefix I should use.
Finally I came across this post, which gave me the exact way to write it. So here it goes:
<target name="SetEnviornmentForBeforeCompilation">
<xmlpoke
file="Configuration.csproj"
xpath="/ns:Project//ns:PostBuildEvent"
value="$(TargetPath) $(SolutionDir) BUILD" >
<namespaces>
<namespace prefix="ns" uri="http://schemas.microsoft.com/developer/msbuild/2003" />
</namespaces>
</xmlpoke>
</target>
1 Comments:
Thank you so much for this post. I've spent a whole week on it but can't figure it out. Thanks again!!! :)
Post a Comment
<< Home