停止构建并显示带有构建事件的消息 [英] Stop build and display message with Build Events

查看:63
本文介绍了停止构建并显示带有构建事件的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Microsoft Visual Studio Express 2012的构建事件来将某些文件复制到$(TargetDir)中.如果找不到特定文件,如何停止构建.目前,我有类似的东西:

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 
)

在适当的情况下,在构建输出对话框中显示truefalse,但我想用

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
) 

exit停止Visual Studio构建项目的位置,somefile was not found则是输出控制台中显示的最后一条消息.

Where exit stops the Visual Studio from building the project and somefile was not found is the last message displayed in the output console.

推荐答案

强制Visual Studio停止生成它只需要设置错误级别

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
)

这篇关于停止构建并显示带有构建事件的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆