如果解决方案失败,Devenv不会返回失败 [英] Devenv is not returning failure if the solution fails

查看:182
本文介绍了如果解决方案失败,Devenv不会返回失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了下面的批处理文件来编译我们的解决方案文件。

I have written below batch file to compile our solution files.

由于发生了一些并行编译,批处理文件告诉重试编译最多5次失败。

As there are some parallel compilation happening, the batch file tells to retry the compilation for max 5 failures.

工作正常。

@echo ON
set WORKSPACE=%~dp0
set build_architecture=x64
set build_type=release

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64


echo %date% %time% : started building DM >> "%WORKSPACE%\DMCompile_%build_architecture%.log"

set x=1
set counter=1
:1
set BuildStep="ThirdParty"
set BuildSoln="w:/ThirdParty/Third Party.sln"
GOTO Build

:2
set BuildStep="Frameworks"
set BuildSoln="w:/Frameworks/Frameworks.sln"
GOTO Build

:3
set BuildStep="Modelmart"
set BuildSoln="w:/ModelMart/ModelMart.sln"
GOTO Build

:4
set BuildStep="Model"
set BuildSoln="w:/ERwin/ERwin Model.sln"
GOTO Build

:5
set BuildStep="Application"
set BuildSoln="w:/ERwin/ERwin Application.sln"
GOTO Build

:6
echo -----------------------Completed Build Process-------------------------------------------
echo %date% %time% : started building DM %ERRORLEVEL% >> "%WORKSPACE%\DMCompile_%build_architecture%.log"

EXIT /B %ERRORLEVEL%

:Build
echo %date% %time% : started %BuildStep% 
echo %date% %time% : started %BuildStep% >> "%WORKSPACE%\DMCompile_%build_architecture%.log"
devenv.com /Build "%build_type%|%build_architecture%" %BuildSoln% > "%WORKSPACE%\%BuildStep%_Build%counter%.log"
echo "ERRORLEVEL for %BuildSoln% is %ERRORLEVEL%"
if %ERRORLEVEL% NEQ 0 goto Failed
echo %date% %time% : Completed %BuildStep% >> "%WORKSPACE%\DMCompile_%build_architecture%.log"
echo %date% %time% : Completed %BuildStep% 
set /a x=%x%+1
GOTO %x%

:Failed
echo "Came to Failed Section..Current Counter Value: %counter%"
set x=1
set /a counter=%counter%+1
if not %counter% GTR 5 (
echo Retrying build %counter% time
set ERRORLEVEL=0
GOTO %x%
)

echo %date% %time% : Build Failed >> "%WORKSPACE%\DMCompile_%build_architecture%.log"
echo.
echo ... Build Failed ...
EXIT /B %ERRORLEVEL%

但是有时候,它会在%ERRORLEVEL%中返回成功而不是失败。



当我打破了日志文件,解决方案失败但仍然返回成功。



But some times, it is returning success instead of failure in %ERRORLEVEL%.

When I checed the log file, the solution fails but still returning as success.

========== Build: 58 succeeded, 152 failed, 0 up-to-date, 0 skipped ==========

任何建议?

推荐答案

您好ukreddy,

Hi ukreddy,

感谢您在此发帖。

根据bat文件,devenv.com将结果返回到.log文件。我发现所有结果都正确添加到.log文件中。所以你的问题应该与bat文件更相关,但我不熟悉bat,我想在一些测试后提出我对这个
问题的看法。

According to the bat file, devenv.com return the result to the .log file. I found all results are correct add into the .log file. So your problem should be more related the bat file, but I am not familiar with bat, I would like provide my opinion for this issue after some test.

在bat中文件,当构建失败时,错误级别的值将设置为0:

In the bat file, the value of errorlevel will be set to 0 when the build fails:

:Failed
echo "Came to Failed Section..Current Counter Value: %counter%"
set x=1
set /a counter=%counter%+1
if not %counter% GTR 5 (
echo Retrying build %counter% time
set ERRORLEVEL=0
GOTO %x%
)

这可能会导致问题。如果bat文件中只有两个项目。当你构建第一个项目时,b uild结果是失败的,所以bat文件将执行上面的代码
片段,ErrorLevel的值将设置为0.然后此bat文件将执行第二次构建,如果此构建结果正确,则ErrorLevel的值应为0.然后构建完成后,错误等级的最终值为0,因此
结果成功,但一个解决方案失败。

This may cause the problem. If you only have two projects in the bat file . When you build the first project, build results is a failure, so the bat file will execute above code snippet, the value of ErrorLevel will be set to 0. Then this bat file will execute the second build, if this build result is correct, the value of ErrorLevel should be 0. Then build complete, the finally value of  ErrorLevel is 0, so the result is successful, but one solution fails.

希望这对您有所帮助。

Hope this help you.


这篇关于如果解决方案失败,Devenv不会返回失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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