NibblyPig
NibblyPig

Reputation: 52922

web.config transform not working when publishing

I have a solution with multiple projects, the transforms work in other projects but not this one. What could be the reason?

The project is an MVC 4 application

The configuration manager for the solution shows that when the solution configuration is LIVE then it should use the LIVE configuration for the project.

There is a Web.config, Web.Live.config, Web.Stage.config

In the Web.Live.config I have this code:

<?xml version="1.0" encoding="utf-8"?>

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

  <system.web>
    <compilation debug="false" xdt:Transform="SetAttributes"></compilation>
  </system.web>

  <system.webServer>
    <rewrite>
      <rules>
        <clear />
        <rule name="Redirect to https" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

I publish it to my web server, ensuring the configuration is set to Live.

The web config on the server does not contain the transformations.

Any ideas?

Upvotes: 0

Views: 279

Answers (1)

NibblyPig
NibblyPig

Reputation: 52922

I've solved this, it seems in this situation I had to add xdt:Transform="Insert" to the <rewrite> tag.

I don't know why I need that considering the default template for a transformed config file contains markup that inserts code without such an attribute that works ok...

Upvotes: 1

Related Questions