visual-studio-2010conditional-compilationbuild-events

Is it possible to use conditional compilation symbols in VS build events?


Say for instance I have a Visual Studio project with a configuration called "MyConfig" and I have the compilation symbol MY_CONFIG_SYMBOL defined.

Is there a macro or command to see if MY_CONFIG_SYMBOL is defined in the pre/post build events? Something like #if MY_CONFIG_SYMBOL, but for the build event?


Solution

  • I finally found an answer. The following works perfectly:

    if "$(DefineConstants.Contains('DEBUG'))" == "True" <command>
    

    This works for any constants defined in the build, but note that the constant is case-sensitive ('DEBUG' != 'Debug').