In ASP.NET Core you're able to quickly change between development and production versions. See:
Use multiple environments in ASP.NET Core | Microsoft Docs[
^]
When you work with WinForms, you're able to achieve something like that with project's variable. I usually declare it in
Program
class:
public static bool isUnderDevelopment = true;
Next, i use some method to load resources depending on
isUnderDevelopment
value.
Sadly, but i haven't found better solution ;(
[EDIT]
Quote:
Note that this does not necessarily correlate with the Debug and Release builds; for example, sometimes I need to run a Release build locally or a Debug build in the live environment.
Assuming that you need to run your application (ASP.NET or WPF) with different configuration files...
Well, i'd suggest to create - let say - "Loader" - an application, which will enable you to choose environment (configuration option) you want to run.
Loader should:
- read options from configuration file (for example:
Loader.config
),
- enable user to select specific option,
- copy specific folder/file into destination folder,
- run your application (start process).
Loader.config
may look like:
="1.0"="utf-8"
<configuration>
<options>
<option key="1" value="Debug"/>
<option key="2" value="Release"/>
</options>
<environments>
<environment key="1" value="local"/>
<environment key="2" value="live"/>
</environments>
<values>
<value key="Debug" value="path_to_bin_debug_folder"/>
<value key="Release" value="path_to_bin_release_folder"/>
<value key="local" value="path_to_local_configuration"/>
<value key="live" value="path_to_live_cofiguration"/>
</values>
<configuration>
As you see,
Loader.config
file is an xml file, which contains 3 main nodes:
{options, environments, values}
with few subnodes. Every subnode is a dictionary entry ;) The last dictionary binds options/environments with their values.
This is how i did that when one of my clients wanted to switch between environments. Note: i addedd extra protection in my application: user can't open application itself, it is required to use
Loader
;)