当批处理系列中没有负面出口时,TFS 构建流程中的批处理如何以 -1 退出

How can a batch exit with -1 with MSBuild in a TFS build flow when there are no negative exits inside the series of batches

我有一个批处理通过 TFS 一直失败,退出为 -1

被调用的批处理没有否定退出。它不直接调用 运行 其他一些可以 return 负退出代码的批处理和命令行工具,但它们都是 called,而不是直接 运行,当我设置了一个失败点,我exit /b 1或者exit 1

....targets (350): The command "call C:\Build\BuildTools\callSigning.bat" exited with code -1.

远程处理失败的框并且运行那里的批处理没有生成错误!

什么可能会触发此 exit -1 与 MSBuild?是否有一些我不知道的奇怪的幕后警告?

在 .proj 文件中,我有这样一行:

<Exec Command="call $(SrcRoot)\BuildTools\callSigning.bat" ContinueOnError="false"/>

并且该批次没有负退出代码...

@echo off
pushd %~dp0

IF EXIST "%~dp0signVerification.log" echo Cert renewed and successfully signed once for this TFS job already&&exit 0

IF NOT EXIST .\renew_certificate.bat echo missing renew_certificate.bat&&exit 1

SETLOCAL EnableDelayedExpansion EnableExtensions

FOR /L %%T IN (1,1,5) DO (
    call %~dp0renew_certificate.bat
    IF NOT "!passed!"=="true" IF "!errorlevel!"=="0" Set passed=true&&exit /b 0
    IF NOT "!passed!"=="true" echo Re-trying signing iteration %%T && call ping 127.0.0.1 -n 61 > nul
)

IF NOT "%passed%"=="true" echo Signing did not pass && exit /b 1
exit /b 0

这可能是 Exec 将您的 Command 文本放入临时目录中的 .exec.cmd 文件并调用 cmd.exe /C [that temporary .exec.cmd] 这一事实的副作用。因此,路径可能不是您所想的那样,并且可能会出现涉及引号的错误。当我使用 Exec 时,我几乎没有机会并通过显式路径,例如:

<PropertyGroup>
  <SomeCommand>
    "$(MSBuildThisFileDirectory)SomeFile.bat" "$(SomeToolsDir)" "$(SomeLogFilePath)"
  </SomeCommand>
</PropertyGroup>
<Exec WorkingDirectory="$(SomeToolsDir)" Command="$(SomeCommand)" />

SomeFile.bat 中:

SET SomeToolsDir=%~1
SET SomeLogFilePath=%~2
SOMEPROGRAM.EXE -logfilepath "%SomeLogFilePath%"