Correct XML XPath query for xmlpoking this web.config

WewsSaboobe

New Member
I have a .config file that looks like this (trimmed for relevance):\[code\]<?xml version="1.0"?><configuration> <configSections> <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> </configSections> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <variable key="projectName" name="projectName" value="http://stackoverflow.com/questions/12732408/ProjectName" /> </nlog><startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>\[/code\]I'm trying to do an XmlPoke with MSBuild in a pre-build task inside TeamCity. My task looks like this:\[code\]<Target Name="SetMSDeployProjectName"> <XmlPoke XmlInputPath="app.config" Namespaces="<Namespace Prefix='x' Uri='http://schemas.microsoft.com/.NetConfiguration/v2.0' />" Query="configuration/nlog/variable[@key = 'projectName']/@value" Value="http://stackoverflow.com/questions/12732408/$(MSDeployProjectName)" /></Target>\[/code\]I can run the MSBuild task/target just fine from the command line, but it keeps telling me "Made 0 Replacements", and of course the config file is unmodified. It seems my XPath query is off, but not sure what it should be. Any ideas? It seems my problem may be related to the fact that \[code\]<variable>\[/code\] is one in a sequence. I'm not sure how to correctly select that element with "name" or "key" of "projectName".
 
Back
Top