0

I have web.config file that overrides items in Settings file like this:

<applicationSettings>
    <MvcApplication.Properties.Settings>
      <setting name="FacebookUrlAuth" serializeAs="String">
        <value>http://URL1.com</value>
      </setting>
      <setting name="GoogleUrlAuth" serializeAs="String">
        <value>http://URL2.com</value>
      </setting>
    </MvcApplication.Properties.Settings>
  </applicationSettings>

And I have web.release.config that transforms these settings:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <applicationSettings>
    <MvcApplication.Properties.Settings>
      <setting name="FacebookUrlAuth" serializeAs="String" xdt:Locator="Match(name)" xdt:Transform="Replace">
        <value>http://AlternativeUrl1.com</value>
      </setting>
      <setting name="GoogleUrlAuth" serializeAs="String" xdt:Locator="Match(name)" xdt:Transform="Replace">
        <value>http://AlternativeUrl2.com</value>
      </setting>
    </MvcApplication.Properties.Settings>
  </applicationSettings>
</configuration>

When I publish solution in Release configuration it works properly (I mean only url's are become different from web.config)

But when Appharbor publishes the application I get a runtime error from the page I use @Settings.Default.FacebookUrlAuth

with the following details:

Unrecognized element 'setting'. (D:\websites\45\31968\17022\0x0001_PublishedWebsites\MVC.Web\web.config line 73)

When I comment all transformation rules, AppHarbor takes these properties from my default web.config and everything works ok. Is it an issue on the AppHarbor side?

friism
  • 19,068
  • 5
  • 80
  • 116
Anubis
  • 2,484
  • 2
  • 22
  • 33
  • friism: You was absolutely right! For some reason Appharbor transforms my config in a wrong way. Please come out to recive a +1 – Anubis Nov 14 '12 at 09:11
  • I have figured out the trouble. As friism said and then deleted his solution: "You can't have multiple setting elements. The error is probably not related to the transformation." and he provided the link to the explanation: http://blogs.msdn.com/b/tess/archive/2010/02/16/system-configuration-configurationerrosexception-unrecognized-element-setting-and-other-unrecognized-elements.aspx I have read the exactely web.config from the AppHarbor hosting and figured out that after the transformation the settings are one lined. So, I think it's a AppHarbor bug. – Anubis Nov 14 '12 at 09:18

1 Answers1

0

You can't have multiple setting elements. The error is probably not related to the transformation.

friism
  • 19,068
  • 5
  • 80
  • 116
  • Please see the way my settings are written. They are not in one line. – Anubis Nov 14 '12 at 08:28
  • You was right! The final trouble was bacause it transforms to one lined setting – Anubis Nov 15 '12 at 08:49
  • @Anubis, I'm surprised you got this working - I am having some problems even getting the transformations executing as described here http://stackoverflow.com/q/14739099/171810, Any ideas? – Teto Feb 07 '13 at 16:12