Asp.net mvc MVC web.config compilation debug=true-需要手动更改吗?
当使用内置模板(文件->新建项目等)创建MVC项目时,web.config会读取Asp.net mvc MVC web.config compilation debug=true-需要手动更改吗?,asp.net-mvc,web-config,web-deployment,Asp.net Mvc,Web Config,Web Deployment,当使用内置模板(文件->新建项目等)创建MVC项目时,web.config会读取 <compilation debug="true" targetFramework="4.5" /> 在Web.Release.config中,我看到了这种转换 <compilation xdt:Transform="RemoveAttributes(debug)" /> 因此,我假设在发布模式下构建时,debug=“true”将消失。然而,我没有看到这一点。 转换是否仅在发布网
<compilation debug="true" targetFramework="4.5" />
在Web.Release.config中,我看到了这种转换
<compilation xdt:Transform="RemoveAttributes(debug)" />
因此,我假设在发布模式下构建时,debug=“true”将消失。然而,我没有看到这一点。
转换是否仅在发布网站时应用?我见过通过拖放方式部署的网站,其中Web.config是从根目录复制过来的(包括debug=“true”)
我只想检查一下,如果通过拖放部署,是否必须手动删除此属性?还是我遗漏了什么?最好是发布您的网站(不同于
F5
或拖放
),以便更新\转换web.config
禁用调试模式
取决于生成配置而不是目标环境,“调试”属性适用于发布生成,特别是当您通常希望禁用调试时,无论您要部署到哪个环境
Visual Studio项目模板将创建一个Web.Release.config转换文件,其中包含从编译元素中删除调试属性的代码
在默认Web.Release.config下面:(对于注释掉的一些示例转换代码,它在compilation元素中包含删除debug属性的代码:)
xdt:Transform=“RemoveAttributes(debug)”属性指定要从部署的web.config文件中的system.web/compilation元素中删除debug属性。这将在每次部署发布版本时完成。回答了您的问题?因此,通过使用拖放,您必须手动编辑配置。编辑您的答案,将您对拖放方案的评论放入其中(这就是问题),并提及首选方式是通过发布选项,该选项将转换应用于配置,我会把它标记为答案。
<?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>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
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>