Ben*_*enA 13 c# asp.net web-config visual-studio-2010
今天我开始玩web.configVS 2010中的转换.首先,我尝试了相同的hello world示例,其中包含许多关于此主题的博客文章 - 更新连接字符串.
我创建了下面显示的最小示例(类似于本博客中的示例).问题是每当我在.csproj文件上右键单击 - >"发布"或右键单击 - >"构建部署包"时,我都没有得到正确的输出.而不是转换的web.config,我没有得到web.config,而是包含了两个转换文件.
我究竟做错了什么?任何帮助感激不尽!
Web.config文件:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="ConnectionString"
connectionString="server=(local); initial catalog=myDB;
user=xxxx;password=xxxx" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Web.debug.config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="ConnectionString"
connectionString="server=DebugServer; initial catalog=myDB;
user=xxxx;password=xxxx"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes"
xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Web.release.config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="ConnectionString"
connectionString="server=ReleaseServer; initial catalog=myDB;
user=xxxx;password=xxxx"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes"
xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Ben*_*enA 23
这些东西不可避免地,答案实际上是在盯着我.的存在xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"在<configuration>web.config中的节点意味着我的转换不匹配.删除它解决了这个问题.
| 归档时间: |
|
| 查看次数: |
8235 次 |
| 最近记录: |