Search code examples
visual-studio-2010web-configslowcheetah

How do I use Visual Studio 2010 config transforms for the applicationSettings section of the web.config?


I just upgraded to Visual Studio 2010, and I am playing around with the Config transforms option for web application projects. I see in the example file how to change the connection strings, but I want to change settings in the applicationSettings (Not appsettings) section. I have not been able to find any information on this.

I tried the following which worked, but I thought there might be a better way:

  <applicationSettings>
    <MyDashboard.Web.Properties.Settings>
      <setting name="SomePath" serializeAs="String" xdt:Transform="Replace" xdt:Locator="Match(name)">
        <value>c:\somewhere test</value>
      </setting>
    </MyDashboard.Web.Properties.Settings>
  </applicationSettings>

Solution

  • Try this. It will replace all the applicationSettings node.

    <applicationSettings xdt:Transform="Replace"> 
        <MyDashboard.Web.Properties.Settings> 
          <setting name="SomePath" serializeAs="String"> 
            <value>c:\somewhere production</value> 
          </setting> 
        </MyDashboard.Web.Properties.Settings> 
      </applicationSettings>