SignTool error : The specified timestamp server either could not be reached

SignTool error : The specified timestamp server either could not be reached

我们有一个 post 构建事件命令来执行代码签名。最近收到以下错误。

Post-Build cmd: 
$(SignToolPath)BuildScripts\SignTool\signtool.exe sign /f $(SignToolPath)BuildScripts\codesign.pfx /p $(CodeSigningPassword) /t http://timestamp.verisign.com/scripts/timstamp.dll /n AP /i "Symantec Class 3 SHA256 Code Signing CA" $(TargetPath)

SignTool error : The specified timestamp server either could not be reached.
/t http://timestamp.verisign.com/scripts/timstamp.dll

以前没见过这个问题。

那么我怎么能再尝试一次在 Post 中进行代码签名 - 根据错误或错误代码构建事件命令?或者在发生任何错误时执行代码签名的任何建议?

使用批处理脚本执行签名操作并添加了基于“ERRORLEVEL”值的重试签名。

@echo off
setlocal enabledelayedexpansion
Set SigningToolPath=%1
Set CodesigningCertsPath=%2
Set SigningPassword=%3
Set TargetProjPath=%4

IF EXIST "%TargetProjPath%" (
    call :SignFile "%SigningToolPath%", "%CodesigningCertsPath%", %SigningPassword%, "%TargetProjPath%", 0
    IF !ERRORLEVEL! NEQ 0 (
        goto end
    )
)
:end
exit /b %ERRORLEVEL%

:SignFile
set "signToolPath=%~1"
set "certPath=%~2"
set "pass=%~3"
set "projFilePath=%~4"
set attempt=%~5
set /a attempt=%attempt%+1

echo.
echo ---signing %TargetProjPath% attempt %attempt%---
"%signToolPath%" sign /f "%certPath%" /p %pass% /fd sha256 /t http://timestamp.digicert.com "%projFilePath%"

IF %ERRORLEVEL% NEQ 0 (
    IF %attempt% LSS 2 (
        call :SignFile "%signToolPath%", "%certPath%", %pass%, "%projFilePath%", %attempt%
    )
)
exit /b %ERRORLEVEL%

并从 MSBuild 脚本调用此批处理文件,如 "$(WorkDirectory)\BuildScripts\SupportFiles\CodeSigningCertificates\signing.bat" "$(SigningToolPath)" "$(CodesigningCertsPath)" "$(SigningPassword)" "$(TargetProjPath)"