title: How do I update an XML attribute from an MSBuild script?
body: <p>I am using <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="noreferrer">MSBuild</a> and <a href="http://msbuildtasks.tigris.org/" rel="noreferrer">MSBuild Community Tasks</a> (using XMLUpdate and <a href="http://blogs.microsoft.co.il/blogs/dorony/archive/2008/01/18/easy-configuration-deployment-with-msbuild-and-the-xmlmassupdate-task.aspx" rel="noreferrer">XMLMassUpdate</a>) to update various sections of my Web.config one thing has me stumped though. If I have: </p>
  
  <pre><code>&lt;configuration&gt;
      &lt;nlog throwExceptions="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
         &lt;targets&gt;
              &lt;target name="file" xsi:type="File" fileName="${logDirectory}\SomeLog.log" layout="${message}"/&gt;
          &lt;/targets&gt;
      &lt;/nlog&gt; 
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and I try to replace the <code>fileName</code> of the <code>target</code> </p>
  
  <pre><code>&lt;XmlUpdate XmlFileName="$(BuildDir)\Builds\%(Configuration.Identity)\_PublishedWebsites\Presentation\Web.config"
             XPath="//configuration/nlog/targets/target[@fileName]"
             Value="${logDirectory}\SomeLog_%(Configuration.Identity).log" /&gt;
  </code></pre>
  
  <p>It reports as being unable to find anything to update, so my question is how can I get the filename attribute to updated?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> Could this be a case of namespace clashes as the NLog section defines its own namespace?</p>
  
  <hr>
  
  <p><strong>UPDATE</strong>: The posted answer declaring the name space does not work.</p>