user547794
user547794

Reputation: 14521

Web Config Transformation Issues

I have a web.config file and a web.release.config file. In web config I define a Mail Queue Folder:

  <appSettings>
    <add key="MailQueue" value="\MailQueue\"/>
  </appSettings>

And this works correctly as long as I publish to IIS in "debug" mode.

I want to use a different folder for production, so in web.release.config I try to replace MailQueue with:

    <appSettings xdt:Transform="Replace">
        <add key="MailQueue" value="\MailQueueProd\"/>
    </appSettings>

However, when I try and publish in "release" mode the MailQueue value does not work correctly. Even if I set web.release.config to be the same path like:

      <appSettings>
        <add key="MailQueue" value="\MailQueue\"/>
      </appSettings>

The mail queue stops working. Am I using this incorrectly?

Upvotes: 3

Views: 299

Answers (1)

Dan
Dan

Reputation: 9847

Replace what you have in web.release.config with this:

<appSettings>
    <add
      key="MailQueue"
      value="\MailQueueProd\"
      xdt:Transform="SetAttributes(value)"
      xdt:Locator="Match(key)" />
</appSettings>

Somewhere in the document hierarchy above or at this code, you also need the following XML namespace declaration:

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

Here's the documentation page: http://msdn.microsoft.com/en-us/library/dd465318.aspx

Upvotes: 1

Related Questions