我做了一個web.config
(full file,它不顯示XML錯誤)發佈不轉換web.config?
<?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 2011-03-25 15:13:44
@Jimmy在生成日誌中說,它是在'Staging'中編譯的。有一個'Release'的轉換文件,但它也不起作用。 – BrunoLM 2011-03-25 15:15:35
您是否看到表示正在執行轉換的消息?像我的說:「使用Web.Beta.config轉換成obj \ Beta \ TransformWebConfig \轉換\ Web.config。」Web.config。「 – CodingGorilla 2011-03-25 15:19:35