Swallowing errors in pre-build steps in Visual Studio 2010

Andrey picture Andrey · Apr 27, 2011 · Viewed 10.9k times · Source

My solution has a bunch of projects one of which is a windows service; I have a prebuild step to stop the service and a postbuild step to restart it (this way the windows service exe is not locked when VS is building/overwriting it).

on pre-build: 
net stop myservice

on post-build:
net start myservice

If the service is not running while I'm starting the build, the net stop command fails and that prevents the build from proceeding.

What can I do to still force the build even if the pre-build step failed?

Answer

Andrey picture Andrey · Apr 27, 2011

I figured it out - you simply need to add the following statement at the end:

SET ERRORLEVEL = 0

or simply:

EXIT 0