Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use an OR statement in a Post-Build event?

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.

like image 883
Xaisoft Avatar asked Dec 11 '12 17:12

Xaisoft


People also ask

How do I debug a post-build event in Visual Studio?

Another way is to check the bin\debug dir for 'PreBuildEvent. bat' or 'PostBuildEvent. bat' which are the file that Visual Studio creates and run during the build events, if there is an error the files remain in the output dir and you can run them manually and spot the error.

How do I create a post-build event in Visual Studio?

In the Post-build event command line box, specify the syntax of the build event. Add a call statement before all post-build commands that run . bat files. For example, call C:\MyFile.

How do I run a batch file in post-build event?

If you go to the Properties page for your project, you should select the Build Events tab. You can type in the call to your batch file in the Post-build event command line text box. If you want to refer to the batch file using the paths included in the project or solution, you can click on the Edit Post-Build...

What is PostBuildEvent?

PostBuildEvent. This event executes after the build finishes. The following table lists each use-in-build element: XML Element. Description.


2 Answers

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

like image 176
Chris Leyva Avatar answered Oct 04 '22 03:10

Chris Leyva


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"***))

like image 43
Scott Software Avatar answered Oct 04 '22 02:10

Scott Software