6

Is there a way to have a not equal condition in build events ?

Like this:

if $(ConfigurationName) != Debug xcopy ...

Note that this is build event (batch-like syntax), not MSBuild task (which indeed supports != ).

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
EdRbt
  • 329
  • 1
  • 6
  • 17
  • No, it doesn't work, it seems that '!=' is not accepted by the compiler – EdRbt Jan 08 '16 at 17:14
  • This is a bit of a hack, but you could make it work: http://stackoverflow.com/a/19089118/656243 – Lynn Crumbling Jan 08 '16 at 17:17
  • 2
    IMO this is not a duplicate. The OP is asking about a "not equal" operator in build event syntax in general, not specifically about the debug build condition; my suggestion: According to [msdn](https://msdn.microsoft.com/de-de/library/ms165412.aspx), build event syntax is DOS command syntax, so this should work: if $(ConfigurationName) NEQ Debug xcopy ... – Cee McSharpface Jan 08 '16 at 17:28
  • Duplicate covers many options for "else" branch... Also I think simple `neq` should work too (as VS basically runs bat file to run events. You can get all bat comparison operators in CMD by typing `help if`). – Alexei Levenkov Jan 08 '16 at 17:29

1 Answers1

12

Update:

My bad, I thought it's for MSBuild. But if it's for only Build event than it will work like batch script

if not "$(ConfigurationName)" == "Debug" (
  echo "hello world"
)

For MSBuild

It's like following

Condition="'$(Configuration)'!='DEBUG'"

ex:

<When Condition=" '$(Configuration)'!='DEBUG' ">
....
</When>

See details MSBuild condition

Nikson Kanti Paul
  • 3,394
  • 1
  • 35
  • 51