Web Config Transform not working

HaBo picture HaBo · Jan 12, 2012 · Viewed 63.1k times · Source

In a .NET MVC 3.0 Application I have the following configuration in appSettings:

web.config

<appSettings>
<add key="SMTPHost" value="mail.domain.com"/>
    <add key="SMTPUsername" value="[email protected]"/>
    <add key="SMTPPort" value="25"/>
    <add key="SMTPPwd" value="mypassword"/>
    <add key="EmailFrom" value="[email protected]"/>
</appSettings>

For debugging, I have the following configuration transform defined:

web.Debug.config

<appSettings>
    <add  key="SMTPPort" value="58" xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>

And I run the application in debug mode, but my SMTP port is still taking the value from the web.config, not web.Debug.config.

Can anyone suggest what could be wrong in this configuration?

Answer

devdigital picture devdigital · Jan 12, 2012

The Web.config transforms are only applied as part of a publish operation.

If you wish this to be done as part of an app.config build operation, then you can use the SlowCheetah - XML Transforms Visual Studio plugin:

http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5