Question

My Web.Config Transformations are not getting published - and I think the error has to do with these warning(s) I'm getting.

Using Visual Studio 2010, I'm playing around with my Web.Config / Web.Config.Debug files.

In my .Debug file, I get the following warning listed numerous times.

No element in the source document matches '/configuration'

I think it lists it for each section that exists in the .Debug file.

So with the following sample Web.Config.Debug file .. that will be listed twice. (i'm guessing, the first one is for <connectionStrings>..</> and the second is for <system.webServer>...</.> )

<?xml version="1.0"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

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

    <connectionStrings>
        <add name="Foo" connectionString="Server=foo;Database=Foo;uid=foo;password=foo" providerName="System.Data.SqlClient"
            xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>

    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <clear />
                <add name="ETag" value="Dev_IIS" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>

</configuration>

Can anyone help, please?

Was it helpful?

Solution

I found this blog post which suggests that the transformer is choking on xmlns= attributes.

I changed my Web.config file from this:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
    etc...

to this:

<configuration>
  <connectionStrings>
    etc...

...and lo and behold, it works!

OTHER TIPS

I created a new web application project (targetting .net 4.0), changed the Web.Release.config to contain exactly what you pasted above. I then went to web.config and added the following:

    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
    <add name="Foo" />  <------------------------added this
  </connectionStrings>

I then changed the configuration to release and published the web application. The published application contained the following in web.config

<add name="ApplicationServices"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
     providerName="System.Data.SqlClient" />
<add name="Foo"
     connectionString="Server=foo;Database=Foo;uid=foo;password=foo"
     providerName="System.Data.SqlClient" />  <-------this got added

So I am not sure where the problem is in your case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top