4

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: 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>
Community
  • 1
  • 1
Ole Lynge
  • 4,457
  • 8
  • 43
  • 57

3 Answers3

8

Try this in your substitutions file

<connectionStrings xmu:action="remove" />

This should completeley remove the <connectionStrings> tag.

jmaragon
  • 96
  • 1
  • 3
1

Give this a shot:

<connectionStrings>
  <add xmu:key="name" key="connectionString1" xmu:action="remove" />
</connectionStrings>
Tom Lianza
  • 4,012
  • 4
  • 41
  • 50
1

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=)

nickhar
  • 19,981
  • 12
  • 60
  • 73
tas
  • 11
  • 1