문제

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);
도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top