Question

I have asp.net mvc 4 project where try to use transform config, where have some default values and when I try to change to release mode some default values change to release values, but it isnt work. When I try to change to release mode and build application I have nothing changes. Here is my default values in Web.config:

<appSettings>
    <add key="appId" value="####"/>
    <add key="appSecret" value="####"/>
    <add key="hostName" value="####"/>
  </appSettings>

And here is what I have in my Web.Release.config:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <appSettings>
    <add key="appId" value="!!!!" xdt:Transform="Replace" xdt:Locator="Match(name)" />
    <add key="appSecret" value="!!!!" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
    <add key="hostName" value="!!!!" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
  </appSettings>
</configuration>

Does anybody help me?

Was it helpful?

Solution

Using xdt:Locator="Match(name)", you're trying to match an attribute name which does not exist. You're looking for key for the appSettings:

<add key="appId" value="!!!!" xdt:Transform="Replace" xdt:Locator="Match(key)" />
<add key="appSecret" value="!!!!" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="hostName" value="!!!!" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top