我的web.config转换没有发布 - 我认为错误与我得到的这些警告有关。

使用Visual Studio 2010,我正在玩我的 Web.Config / Web.Config.Debug 文件。

在我的 .Debug 文件,我收到以下警告列出了无数次。

No element in the source document matches '/configuration'

我认为它列出了每个 部分 这存在于 .Debug 文件。

因此,使用以下示例web.config.debug文件..将列出两次。 (我猜,第一个是 <connectionStrings>..</> 第二是 <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>

有人可以帮忙吗?

有帮助吗?

解决方案

我发现 这篇博客文章 这表明变压器在XMLNS =属性上窒息。

我从此更改了我的web.config文件:

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

为此:

<configuration>
  <connectionStrings>
    etc...

...然后瞧瞧,它有效!

其他提示

我创建了一个新的Web应用程序项目(Targetting .NET 4.0),更改了Web.Release.config以包含您上面粘贴的内容。然后,我去了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" />  <------------------------added this
  </connectionStrings>

然后,我更改了配置以发布并发布了Web应用程序。已发布的应用程序包含以下内容。

<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

因此,我不确定您的情况在哪里。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top