发布不转换web.config吗? [英] Publish is not transforming web.config?
本文介绍了发布不转换web.config吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我制作了 web.config
( 完整文件 ,它不会显示XML错误)
I made a web.config
(full file, it doesn't show XML errors)
<?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
模式发布(正确点击网站>发布>方法:文件系统...)
I am publishing in Staging
mode (right click website > Publish > Method: File System ...)
------ 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
时,它并没有改变。
But when I look at the web.config
in the output folder it isn't changed.
I在生成日志中找到以下内容:
I found the following on the Build log:
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.
可能是什么问题?我对吗?
What could be the problem? Am I doing this right?
推荐答案
我发现了两件事:
- 您不能在
< configuration>
标记上设置名称空间(例如:对于< location path = 。 libraryInChildApplications = false>
) - 您必须注意转换文件中的正确层次结构。
- You cannot set a namespace on the
<configuration>
tag (ex: for<location path="." inheritInChildApplications="false">
) - You have to watch for the correct hierarchy in the transform file.
类似
<configuration>
<location>
<connectionStrings>
而不是
<configuration>
<connectionStrings>
这篇关于发布不转换web.config吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文