Web.config的Release版本和Debug版本不一样的奥秘
2017-04-14 14:07
363 查看
VS编译完后,release版本的web.config(或者app.config) 为什么不一样那?
我们查看一下项目结构,会发现有两个版本的config文件存在:
打开web.Debug.config,这个文件没有什么,就是正常的配置。
打开web.Release.config文件,发现了奥秘。下面是VS自己默认创建的内容:
<?xml version="1.0" encoding="utf-8"?> <!-- 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"> <!-- In the example below, the "SetAttributes" transform will change the value of "connectionString" to use "ReleaseSQLServer" only when the "Match" locator finds an attribute "name" that has a value of "MyDB". <connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings> --> <system.web> <!-- In the example below, the "Replace" transform will replace the entire <customErrors> section of your web.config file. Note that because there is only one customErrors section under the <system.web> node, there is no need to use the "xdt:Locator" attribute. <customErrors defaultRedirect="GenericError.htm" mode="RemoteOnly" xdt:Transform="Replace"> <error statusCode="500" redirect="InternalError.htm"/> </customErrors> --> </system.web> </configuration> |
仔细读一下,发现这里面给出了两个例子:
第一个例子是如何找到web.Debug.config文件中connectionStrings节点下面名字为MyDB的键,然后将内容替换成指定的内容。
第二个例子是如何将web.Debug.config文件中某个节点整体替换成指定的内容。
另外还可以看到给出了一个网址,可以参考进行更高级的操作:
http://schemas.microsoft.com/XML-Document-Transform
看到这里,就明白Release版本的web.config是怎么产生的了。
相关文章推荐
- 爱上MVC~Web.Config的Debug和Release版本介绍
- 注意CGFloat默认初始值在Debug和Release版本中是不一样的
- 为Debug和Release分别设置Web.config
- 关于Web.config的debug和release.config文件
- 为Debug和Release分别设置Web.config
- BuildConfig自定义字段在debug模式和release版本的使用
- C++,局部变量在栈上的地址,Release 和 Debug版本是不一样的
- qt条件编译debug和release版本--qmake之CONFIG(debug, debug|release)
- Asp.Net多环境Web.config配置-Web.Debug.config Web.Release.config
- Web.Debug.config和Web.Release.config设置xdt:Transform无效的解决办法
- vs2015 工程中 Web.Release.config和Web.Debug.config文件无效的处理办法
- qt条件编译debug和release版本--qmake之CONFIG(debug, debug|release)
- 为Debug和Release分别设置Web.config
- Web.Config/Web.Debug.Config/Web.Release.Config 根据发布环境转换Web.Config
- DEBUG和RELEASE 版本差异及调试相关问题
- 在原有VS2005基础上安2008测试版本2以后出现:配置节错误:web.config/protocols 解决方法。
- DEBUG和RELEASE 版本差异及调试相关问题:
- 程序Debuge版本编译通过,Release版本出现链接错误,解决办法
- 程序Debuge版本编译通过,Release版本出现链接错误,解决办法
- VC的Debug和Release版本