XmlMassUpdate - How to remove a node

We would like to use msbuild to clear the connectionStrings section from the web.config file.

What is the easiest way to do this?

Earlier we used XmlMassUpdate to replace values ​​(see also this question: XmlMassUpdate - Replace Node value ), but we did not find a way to completely remove it.

More details:

We would like to change the section in web.config from

  <connectionStrings>
   <add name = "connectionString1" connectionString = "Data Source = localhost \ SQLEXPRESS; Initial Catalog = Db1; Integrated Security = True" />
 </connectionStrings> 

to

  <connectionStrings>
 </connectionStrings> 
+4
source share
3 answers

Try this in your notes file

<connectionStrings xmu:action="remove" /> 

This should completely remove the <connectionStrings> .

+8
source

Take a picture:

 <connectionStrings> <add xmu:key="name" key="connectionString1" xmu:action="remove" /> </connectionStrings> 
+1
source

I tried something similar to the following, and it seemed to work:

 <connectionStrings> <add xmu:key="name" name="connectionString1" xmu:action="remove" /> </connectionStrings> 

(note name= instead of key= )

+1
source

Source: https://habr.com/ru/post/1300855/


All Articles