Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run visual studio pre-build events in windows and mac?

I have a pre-build event as follows:

ver
if %errorlevel% EQU 0 (
   REM some code
) else (
   REM some code
)

When running this on a mac os machine, ver command throws an error. How can I make this code run on both mac and windows?

like image 893
quldude Avatar asked May 17 '17 01:05

quldude


People also ask

How do I open a build event in Visual Studio?

Go to Solution Explorer and right-click on the project then select Properties then go to the Build Events tab.

How to use 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.

What is PostBuildEvent?

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

How do I get build command in Visual Studio?

To compile source files from within the Visual Studio IDE, choose the Build command from the Build menu. When you build project files by using the Visual Studio IDE, you can display information about the associated vbc command and its switches in the output window.


1 Answers

OK, so I ended up solving the problem by writing two versions of the same script, one for windows, the other for bash/mac. Firstly, I added the following to my pre-build event in visual studio:

enter image description here NOTE: The lack of an extension is on purpose.

Then I added two scripts, one called GenerateConfig.cmd for windows builds. The other script called GenerateConfig for mac builds. You'll also need to make sure the later script has the execute flag on it.

like image 161
Richard Lyle Avatar answered Nov 15 '22 05:11

Richard Lyle