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

Say, for example, I have a Visual Studio project with a configuration called MyConfig, and I have a compilation symbol MY_CONFIG_SYMBOL.

Is there a macro or command to determine if MY_CONFIG_SYMBOLpre / post build exists in the events? Something like #if MY_CONFIG_SYMBOL, but for a build event?

+5
source share
3 answers

I finally found the answer. The following works fine:

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

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

+2
source

, , , . ( .)

:

<#@ include file="debug.incl" #>`

some text1
<# if ( xdebug ) { #>
    foo = bas;
<# } #>
more text

debug.incl :

<# 
bool xdebug = true;
#>

(if) xdebug, xdebug debug.incl.

, debug.incl, . , , , - ...

(I tried debug.tt instead of debug.incl to no avail, switched to .incl, so debug.cs was not created by debug.tt.)


This does not work very well as it does not display compilation conditional characters, although it actually includes the debug attribute of the template!

<#
#if DEBUG 
bool xdebug = true;
#else
bool xdebug = false;
#endif
#>

some text1
<# if ( xdebug ) { #>
    foo = bas;
<# } #>
more text

with <#@ template debug="true" #>vs. <# template debug=false #>you get a conditional conclusion or not, respectively.

0
source

All Articles