windows - 使用构建事件停止构建并显示消息

标签 windows visual-studio batch-file visual-studio-2012 cmd

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

IF EXIST somefile ( 
ECHO true 
) ELSE (
ECHO false 
)

根据需要在构建输出对话框中显示 truefalse 但我想用

替换 ECHO false
ELSE (
ECHO somefile was not found
exit
) 

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

最佳答案

强制 visual studio 停止它只需要设置错误级别的构建

IF NOT EXIST somefile (
  echo somefile was not found
  echo ERROR: This will be displayed in the error list of VS
  exit /b 1
)

关于windows - 使用构建事件停止构建并显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19360054/

相关文章:

visual-studio - Visual Studio 扩展性 : How to control the loading order of components?

带步骤的 PowerShell 循环范围

python - Windows 上的 fcntl 替代品

java - 使用 Java 代码以管理员身份运行 cmd

c# - 隐藏通过电子邮件发送的附件中的文件路径c#

c# - 无法使用 .NET Core 2.0 加载文件或程序集

windows - 在批处理的输入参数中转义 "double quotes"

windows - 根据批处理文件中的 IF ELSE 条件设置变量不同的值

java - txt文件的读取输出有空格

c++ - 如何将 objdump 结果发送到文件?