在发布时从web.config中删除debug ="true"的好方法是什么?

ili*_*ian 5 cruisecontrol.net msbuild visual-studio-2008

我使用VS 2008进行开发,并使用CCNet构建,测试和部署我们的应用程序到登台服务器.我希望能够debug="true"在部署过程中从web.config中删除该设置.

我知道我可以<deployment retail="true"/>在machine.config中设置,但我并不总是能够访问我们部署的服务器.我可以写一些代码来从web.config中删除设置,但我想知道是否有一种方法我可以用msbuild或CCNet开箱即用.

Rub*_*ink 6

您可以使用MSBuild社区任务并执行:

<XmlUpdate 
        XmlFileName="web.config" 
        XPath="//configuration/system.web/compilation/@debug" 
        Value="false"/>
Run Code Online (Sandbox Code Playgroud)

或者您可以使用各种内置的Visual Studio转换技术:

<configuration xmlns:xdt="...">
<compilation xdt:Transform="RemoveAttributes(debug,batch)">
</compilation>
</configuration>

  • VS2005和2008 Web部署项目允许您替换Web配置的部分(如Paddy链接到的)
  • 不确定,但MSDeploy在此方面具有某种形式的功能
  • NAnt有一个xmlpoke

注意,这是在web.config设置debug = false的副本, 作为构建的一部分(我发现太晚了;已投票结束)