11

I am trying to use a conditional with an OR in a Post-Build event, but so far, I have had not luck. The following does not work:

if not "$(ConfigurationName)" == "Debug" or not "$(ConfigurationName)" == "Release" (

but this works:

if not "$(ConfigurationName)" == "Debug" (

With the first one, I get an exist code 4.

Xaisoft
  • 45,655
  • 87
  • 279
  • 432

2 Answers2

12

It seems like there is no provision for OR/AND in conditionals in Pre-Post Build events, at least according to its lack of documentation over here: http://technet.microsoft.com/en-us/library/bb490920.aspx

You would have to re-write your IF statement to do what you would want to do.

if not "$(ConfigurationName)" == "Debug" (
   rem do something
) else if not "$(ConfigurationName)" == "Release" (
   rem do the same thing as above
)

Hope that helps, though your conditions don't make sense to me. :-)

Chris Leyva
  • 3,478
  • 1
  • 26
  • 47
  • I think he he created a custom configuration (or perhaps more than one) and he wants to target those instead of Debug/Release. – eburgos Aug 09 '13 at 13:38
  • Anyway, I tried this solution to a similar problem. It worked for me but I had to remove the double quotes as in if not $(ConfigurationName) == Debug . Maybe both works – eburgos Aug 09 '13 at 13:39
1

If you want to execute some logic in a Post-Build event where the ConfigurationName is not "Debug" or "Release", try the following:

if not "$(ConfigurationName)" == "Debug" (if not "$(ConfigurationName)" == "Release" (***ADD LOGIC HERE - ConfigurationName is not "Debug" or "Release"***))

Scott Software
  • 499
  • 2
  • 4
  • 17