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

3

5

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.

Barbet answered 10/2, 2010 at 16:1 Comment(0)
O
6

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)

Oletta answered 10/2, 2010 at 16:5 Comment(0)
M
2

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

Myrtia answered 10/2, 2010 at 16:8 Comment(0)
C
0

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>
Carmancarmarthen answered 8/5, 2013 at 8:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.