+ <Exec Condition="'$(SignFiles)'=='true'" Command="REM Sign target file(s). Use new SSL.com Extended Validation Code Signing certificate that requires
REM special setup and use of their eSignerCKA. That setup is done in the Azure Pipeline build script.
REM Then, use of the signtool.exe should remain pretty much the same. We will now have signtool.exe
REM lookup the certificate by the subject/issued to name, instead of the thumbprint. Hopefully that
REM won't change when the certificate is renewed. We also don't have to specify the certificate password
REM here since we are effectively accessing it from the Windows Certificate Store, and the setup of
REM the SSL.com eSignerCKA has our credentials.
REM There are a ton of Microsoft files already signed, so no need to waste time. We'll try to move them
REM and then sign the remaining, then move the files back. Signing all 300+ files took over 20 minutes.
mkdir "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\aspnetcorev2*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\clr*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\coreclr.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\createdump.exe" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\host*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\Microsoft.*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\mscor*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\msquic.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\netstandard.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\Newtonsoft.Json*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\System.*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"
move /Y "$(ProjectDir)bin\$(Configuration)\Publish\WindowsBase.dll" "$(ProjectDir)bin\$(Configuration)\Publish\signed"

REM Sign all remaining files. It's not perfect, but much better.
"$(SignToolPath)" sign /v /fd SHA256 /tr http://ts.ssl.com /td sha256 /n "One Identity LLC" "$(ProjectDir)bin\$(Configuration)\Publish\*.dll" "$(ProjectDir)bin\$(Configuration)\Publish\*.exe"

REM Finally, move all files back.
move "$(ProjectDir)bin\$(Configuration)\Publish\signed\*.*" "$(ProjectDir)bin\$(Configuration)\Publish\"
rmdir "$(ProjectDir)bin\$(Configuration)\Publish\signed"" />
0 commit comments