Windows 停止生成并显示包含生成事件的消息
我正在使用Microsoft Visual Studio Express 2012的生成事件将一些文件复制到Windows 停止生成并显示包含生成事件的消息,windows,visual-studio,batch-file,visual-studio-2012,cmd,Windows,Visual Studio,Batch File,Visual Studio 2012,Cmd,我正在使用Microsoft Visual Studio Express 2012的生成事件将一些文件复制到$(TargetDir)。如果找不到特定文件,如何停止生成。目前我有一些类似于: IF EXIST somefile ( ECHO true ) ELSE ( ECHO false ) 在构建输出对话框中显示true和false,但我想将ECHO false替换为 ELSE ( ECHO somefile was not found exit ) 其中exit停止Visual
$(TargetDir)
。如果找不到特定文件,如何停止生成。目前我有一些类似于:
IF EXIST somefile (
ECHO true
) ELSE (
ECHO false
)
在构建输出对话框中显示true
和false
,但我想将ECHO false
替换为
ELSE (
ECHO somefile was not found
exit
)
其中
exit
停止Visual Studio生成项目,并且somefile未找到
是输出控制台中显示的最后一条消息 强制visual studio停止生成只需设置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
)
此
exit
命令在作为预生成事件发出时,不会阻止Visual Studio生成项目。给出错误级别会使Visual Studio抱怨预生成步骤本身Error 1命令“IF not EXIST somefile1(echo somefile not found exit 3)”退出时代码为3。
这更像是一次黑客攻击。退出不会阻止它,但它应该具有错误级别。此外,您还可以添加一些错误输出,这些输出将显示在错误列表中,而不仅仅显示在生成输出中。我始终使用prebuild.bat文件,VS会报告批处理文件的错误(就像它在链接时报告错误一样)Fehler 2错误MSB3073:Der Befehl“D:\Projekte\xyz\Tools\prebuild.bat:VCEnd”wurde mit dem代码2 beendet.C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.cppcomon.targets 103
您不能直接访问它们,只能作为批处理参数访问。我的预链接事件是。我使用引号来避免从批处理中访问$(ProjectDir)\PreBuild.bat“$(SolutionDir)”
参数时出现空格或特殊字符问题%1