ilivewithian
ilivewithian

Reputation: 19702

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.

Upvotes: 5

Views: 1170

Answers (3)

Ruben Bartelink
Ruben Bartelink

Reputation: 61865

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

Upvotes: 6

Asier
Asier

Reputation: 57

My solution for CCNET with the Web.config transformation:

<tasks>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>E:\VersionesCC\Trunk_4\SBatz\Gertakariak_Orokorrak\GertakariakMS\Web</workingDirectory>
        <projectFile>GertakariakMSWeb2.vbproj</projectFile>
        <targets>Build</targets>
        <timeout>600</timeout>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
        <buildArgs>
            /noconsolelogger /p:Configuration=Release /v:diag
            /p:DeployOnBuild=true
            /p:AutoParameterizationWebConfigConnectionStrings=false
            /p:DeployTarget=Package
            /p:_PackageTempDir=E:\Aplicaciones\GertakariakMS2\Web
        </buildArgs>
        </msbuild>
</tasks>

Upvotes: 0

Paddy
Paddy

Reputation: 33867

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

Upvotes: 2

Related Questions