Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect debug/release in visual studio pre/post-build command line?

How can I detect Debug or Release mode from command line pre-build or post-build window?

I tested the code below, it works in code text window. Can it be convert to command line code? If can, how to do it, thanks.

bool debugging = false;
#if DEBUG
    debugging = true;
    // do something like to move ../debug/bin/ to somewhere.
#else
    debugging = false;
    // do something like to move ../debug/bin/ to somewhere.
#endif

Console.WriteLine(debugging);
like image 486
Nano HE Avatar asked Feb 24 '23 07:02

Nano HE


1 Answers

You can check the value of the $(ConfigurationName) variable.

It is different to what you used in your code sample. #if DEBUG is a conditional compilation directive which depends upon whether DEBUG has been defined as a symbol or not. The ConfigurationName variable depends upon what build configuration you have specified (which is independent of the conditional compilation symbols).

like image 136
slugster Avatar answered Apr 08 '23 14:04

slugster