Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Visual Studio pre-build events guaranteed to finish before compiling starts?

I'm using a pre-build event in Visual Studio to run a batch (.bat) file that performs some code generation (specifically, I'm running SqlMetal.exe to generate LinqToSql code).

Is the batch file guaranteed to finish before the compilation begins? Or does it run the batch asynchronously?

Bottom line: I want to make sure the new code gets compiled, not the old code.

If it's not guaranteed -- what solutions are available?

like image 486
devuxer Avatar asked Jan 04 '10 00:01

devuxer


2 Answers

Yes. But note that if you have more than one step in your pre-build, only the last step will be checked for errors. See Gotcha! Visual Studio Pre/Post-Build Events for more info.

like image 182
Duncan Bayne Avatar answered Oct 13 '22 12:10

Duncan Bayne


The batch file will complete only after the process it has started has itself completed, unless you use the start command in the batch file. As a simple test, you could just create a batch file like this:

notepad.exe

And set that as your pre-build event. You will see that the build starts only after you shut down notepad.

like image 31
Tarydon Avatar answered Oct 13 '22 10:10

Tarydon