@echo off
setlocal EnableDelayedExpansion

set "ProductName=C4IT Light Identity Access Management"
set "SignTool=..\..\Common Code\Tools\signtool.exe"
set "TimeStamp=http://rfc3161timestamp.globalsign.com/advanced"
set "SignCertificateSubject=Consulting4IT GmbH"
set "SignCertificateEmail=info@consulting4it.de"

if defined LIAM_SIGN_CERT_SUBJECT (
    set "SignCertificateSubject=%LIAM_SIGN_CERT_SUBJECT%"
)

REM Alle passenden Dateien in einer Variablen sammeln
set "FileList="
for %%F in (".\bin\Release\Liam*.dll") do (
    set "FileList=!FileList! "%%F""
)

REM SignTool mit allen gesammelten Dateien aufrufen
echo Signing all matching files at once...
echo Expected signer: %SignCertificateSubject% ^<%SignCertificateEmail%^>
if defined LIAM_SIGN_CERT_THUMBPRINT (
    call "%SignTool%" sign /sha1 "%LIAM_SIGN_CERT_THUMBPRINT%" /tr %TimeStamp% /td SHA256 /fd SHA256 /d "%ProductName%" !FileList!
) else (
    call "%SignTool%" sign /n "%SignCertificateSubject%" /tr %TimeStamp% /td SHA256 /fd SHA256 /d "%ProductName%" !FileList!
)

pause
