Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check the active solution configuration Visual Studio built with at runtime?

I would like to enable/disable some code based on a custom solution configuration I added in Visual Studio. How do I check this value at runtime?

like image 539
Luke Avatar asked Aug 28 '08 01:08

Luke


People also ask

How do I find solution configuration in Visual Studio?

The standard Visual Studio toolbar contains a Start button and a solution configuration drop-down to the right of the Start button. This list allows users to choose the configuration to be started when F5 is pressed, create their own solution configurations, or edit an existing configuration.

Where are Visual Studio build configurations stored?

The configuration and the platform control where built output files are stored. Normally, when Visual Studio builds your project, the output is placed in a project subfolder named with the active configuration (for example, bin/Debug/x86), but you can change that.

How do I open configuration properties?

In the ConfigurationManager , right-click a configuration name and click Properties.

How do I add Release configuration in Visual Studio?

In Solution Explorer, right-click the project and choose Properties. In the side pane, choose Build (or Compile in Visual Basic). In the Configuration list at the top, choose Debug or Release. Select the Advanced button (or the Advanced Compile Options button in Visual Basic).


2 Answers

In each project's properties under the build section you can set different custom constants for each solution configuration. This is where you define custom pre-compiler directives.

like image 66
Luke Avatar answered Oct 12 '22 02:10

Luke


You can use precompiler directives within Visual Studio. The #if directive will allow you to determine if you are going to include code or not based on your custom solution configuration.

like image 35
Jon Limjap Avatar answered Oct 12 '22 01:10

Jon Limjap