Setting debug=false in web.config as part of build
Asked Answered
P

5

6

Is it possible to instruct the aspnet_compiler to set debug=false in the web.config?

My intention is to automate this as part of the nant build process. I am open to suggestions other than xml parsing

Pauli answered 24/3, 2009 at 16:5 Comment(0)
T
10

Have you thought about using <xmlpoke>?

<xmlpoke file="${Build.WebConfig}" 
    xpath="/configuration/system.web/compilation/@debug" 
    value="false">
</xmlpoke>

NAnt Home Page

XML Poke Documentation

Traverse answered 24/3, 2009 at 16:17 Comment(1)
I recommend adding links to the NAnt home page and the xmlpoke documentation.Glovsky
A
3

I would suggest using entirely different config files for each environment(prod, test, staging in our case). Depending on the build you would just use the required config, no mess, less fuss. Hanselmen has example on how to do this in Visual Studio and if you read the first comment Phil Hack has got it working with NAnt.

 <target name="configMerge">  
     <copy file="${sourcefile}"  
         tofile="${destinationfile}" overwrite="true">  
       <filterchain>  
         <expandproperties />  
       </filterchain>  
     </copy>  
   </target>  

In Addition, if you are using VS 2010 you can now use web.config transforms

Amethist answered 24/3, 2009 at 16:21 Comment(0)
P
2

The way I tackle this is I have seperate configuration files for each deployment environment:

  • Production
  • Staging
  • Development

Upon the "build script", I copy the config files for the type I am building. For example, on Staging I would copy the /configs/staging/*.config into the root of the website. Then, my script would call aspnet_compiler to compile the application.

Presentment answered 24/3, 2009 at 16:14 Comment(2)
+1. I actually take this a step further and deploy multiple web.config files, named web.config.empty, web.config.default, etc... that way 1) I never overwrite an existing web.config file, and 2) users can review the settings used in different ways.Acidify
It also helps when you have a 10+ person team of developers, all with SQL installed locally, Vista IIS7 vs XP's IIS6 configs, etc. The team just has to be trained that "when a config is changed, make sure is propogated throughout all other config files"Presentment
W
0

I've been using this tool as part of my build chain. It allows conditional configuration settings within a single xml file based on build settings.

http://xmlpreprocess.sourceforge.net/

Wisteria answered 24/3, 2009 at 16:30 Comment(0)
K
0

Using web deployment projects you can swap out different sections of your web.config after your build.

Kandicekandinsky answered 24/3, 2009 at 17:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.