问题
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
回答1:
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
回答2:
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
回答3:
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.
回答4:
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/
回答5:
Using web deployment projects you can swap out different sections of your web.config after your build.
来源:https://stackoverflow.com/questions/678096/setting-debug-false-in-web-config-as-part-of-build