7

How do I use MSBuild Community Tasks to delete a node in web.config. I can update a node using XmlUpdate task but I cannot delete a node. Any ideas.

Subhasis
  • 714
  • 3
  • 14
  • 28
  • 1
    Funny, i never noticed that before. Maybe try using PowerShell from MSBuild to do what you need? Or submit a patch with a custom 'XmlDelete' task! :) – Zach Bonham Dec 24 '10 at 14:54

1 Answers1

11

The XmlUpdate task can do it. I am using the nightly build from 11/30/2010.

 <XmlUpdate
      XmlFileName="web.config"
      XPath="/configuration/appSettings/add[@key='setting2']" 
      Delete="true" />

The XmlFile task of the MSBuild Extension Pack can also do it:

 <XmlFile
      TaskAction="RemoveElement"
      File="web.config"
      XPath="/configuration/appSettings/add[@key='setting2']" />
Brian Walker
  • 8,658
  • 2
  • 33
  • 35