views:

189

answers:

2

I use VS 2008 to develop and I use CCNet to build, test and deploy our applications to a staging server. I would like to be able to remove the debug="true" setting from web.config as part of the deployment process.

I know I could just set <deployment retail="true"/> in machine.config, but I don't always have that much access the servers we deploy to. I could just write a bit of code to strip the setting from the web.config, but I was wondering if there was a way I could do it out of the box with msbuild or CCNet.

+5  A: 

You can use the MSBuild Community Tasks and do:

<XmlUpdate 
        XmlFileName="web.config" 
        XPath="//configuration/system.web/compilation/@debug" 
        Value="false"/>

Or you can use various built-in Visual Studio transformation techniques:

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

  • VS2005 and 2008 Web Deployment projects allow you to substitute portions of a web config (as Paddy linked to)
  • Not certain but MSDeploy has some form of capability around this
  • NAnt has an xmlpoke

NB this is a duplicate of http://stackoverflow.com/questions/678096/setting-debugfalse-in-web-config-as-part-of-build/678137#678137 (Which I found too late; have put a vote to close on this)

Ruben Bartelink
+2  A: 

Microsoft have supplied web deployment projects for download - these are MS build projects that have a bit of a front end in VS - they allow you to swap out config sections.

http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-support-released.aspx

Paddy