views:

185

answers:

3

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

What is the easiest way to do that?

We have previously used XmlMassUpdate to replace values (see also this question: http://stackoverflow.com/questions/1294438/xmlmassupdate-replace-value-node), but have not found a way to remove it entirely.

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>
+1  A: 

Give this a shot:

<connectionStrings>
  <add xmu:key="name" key="connectionString1" xmu:action="remove" />
</connectionStrings>
tlianza
+3  A: 

Try this in your substitutions file

<connectionStrings xmu:action="remove" />

This should completeley remove the <connectionStrings> tag.

jmaragon
A: 

jmaragon, your code is not working. Gets XmlException: xmu is undeclared prefix