Is it possible to add conditions in app.config file?
I do below in the C# code and I want to do something similar in my app.config
file too.
#if (Debug)
.......
#else
.....
#endif
A configuration file, often shortened to config file, defines the parameters, options, settings and preferences applied to operating systems (OSes), infrastructure devices and applications in an IT context.
We will start with creating an class that can store the instance settings (the <add> element), then we'll create a collection that can store our instances (the <instances> element) and then we'll create the class to manage the Configuration Section (the <sageCRM> element).
While it is necessary when using source control to store the web. config files in the repository, it is best practice to separate out any sensitive or environment specific values to separate files and exclude those files from source control. This article explores some best practices on how to do that.
An application configuration file is an XML file used to control assembly binding. It can redirect an application from using one version of a side-by-side assembly to another version of the same assembly. This is called per-application configuration.
You can try some type of app.config
transforms like this: http://fknut.blogspot.com/2009/11/appconfig-transformation-with-new.html.
Or have multiple app.config
files like app.config.debug
and app.config.release
, and use the appropriate one in your build.
That is not possible, although in Visual Studio 2010 there is a feature that lets you apply configuration-dependent transformations to the Web.config file, but only when publishing using msdeploy.
There is no such transformation for executable applications. You might want to look into using a post-build action to copy a release or debug config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With