Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain build configuration at runtime?

Does anyone know how to get the current build configuration $(Configuration) in C# code?

like image 580
chugh97 Avatar asked May 06 '09 12:05

chugh97


People also ask

How do I find my build config?

To open it, on the menu bar, choose Build > Configuration Manager, or just type Configuration in the search box.

What is runtime configuration?

The Runtime Configurator feature lets you define and store data as a hierarchy of key value pairs in Google Cloud Platform. You can use these key value pairs as a way to: Dynamically configure services. Communicate service states. Send notification of changes to data.

Can we change the configuration file at run time?

You can change and save these using the ConfigurationManager . You can modify and save user settings without restarting. You can't do that with application settings.


1 Answers

If you unload your project (in the right click menu) and add this just before the </Project> tag it will save out a file that has your configuration in it. You could then read that back in for use in your code.

<Target Name="BeforeBuild">
    <WriteLinesToFile File="$(OutputPath)\env.config" 
                      Lines="$(Configuration)" Overwrite="true">
    </WriteLinesToFile>
</Target>
like image 191
Vaccano Avatar answered Oct 03 '22 09:10

Vaccano