Skip to content

Commit 0b52881

Browse files
committed
Add retries to make signing more reliable
1 parent 831a484 commit 0b52881

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

crypto/src/BouncyCastle.Crypto.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
</PropertyGroup>
114114
</Target>
115115
<Target Name="SignAssemblies" AfterTargets="PostBuildEvent" Condition="'$(Configuration)'=='Publish'">
116-
<Exec Command="call &quot;$(ProjectDir)..\..\signfile.bat&quot; &quot;$(TargetPath)&quot;" />
116+
<Exec Command="call &quot;$(ProjectDir)..\..\signfile.bat&quot; &quot;$(TargetPath)&quot;"
117+
IgnoreStandardErrorWarningFormat="true" />
117118
</Target>
118119
</Project>

signfile.bat

+11-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ set SignToolDir=C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\
1414
set SignTool=%SignToolDir%signtool.exe
1515

1616
echo Preparing to sign %Target%
17-
echo "%SignTool%" sign /f "%CodesignFile%" /fd sha256 /tr "%TimestampUrl%" /td sha256 /p "%CodesignPass%" %Target% || exit /b 1
18-
echo Waiting for 20 seconds before issuing command (avoid timeserver rejection)
17+
echo "%SignTool%" sign /f "%CodesignFile%" /fd sha256 /tr "%TimestampUrl%" /td sha256 /p PASSWORD %Target
1918

2019
rem Timestamp server requires 15 seconds or more between signing requests
2120
rem When publishing need to limit parallel build tasks to 1 in Tools|Options|Projects and Solutions|Build and Run
22-
ping -n 20 127.0.0.1 >NUL
21+
set attempts=10
22+
:DoWhile
23+
echo %attempts% attempts remaining
24+
echo Waiting for 30 seconds before issuing command (avoid timeserver rejection)
25+
ping -n 30 127.0.0.1 >NUL
26+
"%SignTool%" sign /f "%CodesignFile%" /fd sha256 /tr "%TimestampUrl%" /td sha256 /p "%CodesignPass%" %Target% && goto EndDoWhile
27+
set /a attempts = %attempts% - 1
28+
if %attempts% gtr 0 goto DoWhile
29+
:EndDoWhile
2330

24-
"%SignTool%" sign /f "%CodesignFile%" /fd sha256 /tr "%TimestampUrl%" /td sha256 /p "%CodesignPass%" %Target% || exit /b 1
25-
26-
"%SignTool%" verify /pa /tw %Target% || exit /b 1
31+
"%SignTool%" verify /pa /tw %Target%

0 commit comments

Comments
 (0)