Stop build and display message with Build Events

会有一股神秘感。 提交于 2020-01-24 12:01:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!