Programmatically check the build configuration

Paul Michaels

Using the DEBUG configuration, I can switch behaviour on and off using this type of syntax:

#if DEBUG
    Console.WriteLine("Debug");
#else
    Console.WriteLine("Not Debug");
#endif

However, if I set up a different configuration, say: TEST then this doesn't work:

#if TEST
    Console.WriteLine("Test");
#else
    Console.WriteLine("Not Test");
#endif

Is there a way to check these?

Tomas Aschan

The DEBUG constant is a special one, and there's a setting for each project in each configuration whether it should be defined. The default is that it's on in Debug and off in Release, but it's completely configurable - open the properties page for a project and look under "Build", and there's a checkbox there saying "Define DEBUG constant."

Thus, defining a new build configuration, does not automatically give you any other compile constants for free. But that doesn't mean you can't create them manually.

To create a compile constant, add it to the list of "Conditional Compilation Symbols" - but make sure to do so in the correct build configuration.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Programmatically check the build configuration

From Dev

JCache: programmatically build replicated cache based on declarative configuration

From Dev

Programmatically build string for printf

From Dev

Programmatically set build description

From Dev

Programmatically Build a State Machine

From Dev

Programmatically build string for printf

From Dev

Programmatically set build description

From Dev

RadioButton check programmatically

From Dev

Programmatically check if gem in bundle?

From Dev

Programmatically check textboxes for completeness

From Dev

cmake: check if file exists at build time rather than during cmake configuration

From Dev

TestNG Programmatically use xml configuration

From Dev

Programmatically getting Jenkins configuration for a plugin

From Dev

TestNG Programmatically use xml configuration

From Dev

How to set ImageResizer configuration programmatically?

From Dev

Spring, Infinispan and JGroups - configuration programmatically

From Dev

Adding a scheduled build to the build configuration

From Dev

How programmatically create and build an .exe?

From Dev

Programmatically build dynamic query with Mongoose

From Dev

Check if Git has changes programmatically

From Dev

How to programmatically check if running on HHVM?

From Dev

How to programmatically check if row is deletable?

From Dev

How to check if a domain exists programmatically?

From Dev

Programmatically check if domains are DNSSEC protected

From Dev

How to check if ufw is running programmatically

From Dev

How to programmatically check if running on HHVM?

From Dev

Check if Git has changes programmatically

From Dev

How to check programmatically if Zookeeper is running?

From Dev

Check if MySQL state is right or not programmatically?

Related Related

  1. 1

    Programmatically check the build configuration

  2. 2

    JCache: programmatically build replicated cache based on declarative configuration

  3. 3

    Programmatically build string for printf

  4. 4

    Programmatically set build description

  5. 5

    Programmatically Build a State Machine

  6. 6

    Programmatically build string for printf

  7. 7

    Programmatically set build description

  8. 8

    RadioButton check programmatically

  9. 9

    Programmatically check if gem in bundle?

  10. 10

    Programmatically check textboxes for completeness

  11. 11

    cmake: check if file exists at build time rather than during cmake configuration

  12. 12

    TestNG Programmatically use xml configuration

  13. 13

    Programmatically getting Jenkins configuration for a plugin

  14. 14

    TestNG Programmatically use xml configuration

  15. 15

    How to set ImageResizer configuration programmatically?

  16. 16

    Spring, Infinispan and JGroups - configuration programmatically

  17. 17

    Adding a scheduled build to the build configuration

  18. 18

    How programmatically create and build an .exe?

  19. 19

    Programmatically build dynamic query with Mongoose

  20. 20

    Check if Git has changes programmatically

  21. 21

    How to programmatically check if running on HHVM?

  22. 22

    How to programmatically check if row is deletable?

  23. 23

    How to check if a domain exists programmatically?

  24. 24

    Programmatically check if domains are DNSSEC protected

  25. 25

    How to check if ufw is running programmatically

  26. 26

    How to programmatically check if running on HHVM?

  27. 27

    Check if Git has changes programmatically

  28. 28

    How to check programmatically if Zookeeper is running?

  29. 29

    Check if MySQL state is right or not programmatically?

HotTag

Archive