【发布时间】:2020-02-29 03:10:48
【问题描述】:
我做了一个web.config(full file,它不显示 XML 错误)
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
...
<location path="." inheritInChildApplications="false">
<connectionStrings>
<add name="ElmahLog" connectionString="data source=~/App_Data/Error.db" />
<add name="database" connectionString="w" providerName="System.Data.EntityClient"/>
</connectionStrings>
</location>
...
使用转换文件 (web.Staging.config)
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="database"
connectionString="c"
providerName="System.Data.EntityClient"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<customErrors defaultRedirect="error.aspx"
mode="RemoteOnly" xdt:Transform="Replace">
</customErrors>
</system.web>
</configuration>
我在Staging模式下发布(右键网站>发布>方法:文件系统...)
------ Build started: Project: Drawing, Configuration: Staging Any CPU ------
Drawing -> D:\Project\bin\Staging\Drawing.dll
------ Build started: Project: MySystem, Configuration: Staging Any CPU ------
MySystem -> D:\Project\bin\Staging\MySystem.dll
...
但是当我查看输出文件夹中的web.config 时,它并没有改变。
我在构建日志中发现以下内容:
D:\Project\Web.Staging.config(3,2): Warning : No element in the source document matches '/configuration'
D:\Project\Web.Staging.config(3,2): Warning : No element in the source document matches '/configuration'
D:\Project\Web.Staging.config(3,2): Warning : No element in the source document matches '/configuration'
Transformed web.config using Web.Staging.config into obj\Staging\TransformWebConfig\transformed\web.config.
可能是什么问题?我这样做对吗?
【问题讨论】:
-
发布时是为
staging还是release构建的? -
@Jimmy 正如构建日志所说,它正在
Staging中编译。Release有一个转换文件,但它也不起作用。 -
您是否看到表明它正在执行转换的消息?就像我说的:“使用 Web.Beta.config 将 Web.config 转换为 obj\Beta\TransformWebConfig\transformed\Web.config。”
-
@Coding 是的,但是之前有一些错误,我刚刚注意到它...更新了我的问题...
-
有没有机会发布有问题的 web.config 文件的第一部分?
标签: asp.net deployment .net-4.0 web-config web-config-transform