问题
I am using the Build Events with Microsoft Visual Studio Express 2012 to copy some files into the $(TargetDir)
. How can I stop the build if a particular file isn't found. Currently I have something like:
IF EXIST somefile (
ECHO true
) ELSE (
ECHO false
)
With displays true
and false
to the build output dialog as appropriate but I'd like to replace ECHO false
with
ELSE (
ECHO somefile was not found
exit
)
Where exit
stops the Visual Studio from building the project and somefile was not found
is the last message displayed in the output console.
回答1:
Forcing visual studio to stop the build it needs only to set the errorlevel
IF NOT EXIST somefile (
echo somefile was not found
echo ERROR: This will be displayed in the error list of VS
exit /b 1
)
来源:https://stackoverflow.com/questions/19360054/stop-build-and-display-message-with-build-events