Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good way to remove debug="true" from web.config on publish?

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.

like image 708
ilivewithian Avatar asked Feb 10 '10 16:02

ilivewithian


People also ask

What is debug true?

debug=true is for debugging during development. It creates debugging symbols used to provide metadata about the current executing code. debug=false is is for deployment to a production server.

What means debug mode?

USB Debugging mode is a developer mode in Samsung Android phones that allows newly programmed apps to be copied via USB to the device for testing. Depending on the OS version and installed utilities, the mode must be turned on to let developers read internal logs.


1 Answers

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:

  • VS2010+ has a full set of transformation techniques built just for this which does it very cleanly:

<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 Setting debug=false in web.config as part of build (Which I found too late; have put a vote to close on this)

like image 168
Ruben Bartelink Avatar answered Nov 15 '22 08:11

Ruben Bartelink