forked from dockpanelsuite/dockpanelsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign.ps1
49 lines (42 loc) · 1.42 KB
/
sign.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$foundCert = Test-Certificate -Cert Cert:\CurrentUser\my\46B0B01ABEEC5A041CA86E6B288A866BC7349EAD -User
if(!$foundCert)
{
Write-Host "Certificate doesn't exist. Exit."
exit
}
Write-Host "Certificate found. Sign the assemblies."
$signtool = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64\signtool.exe"
foreach ($line in Get-Content .\sign.txt) {
& $signtool sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /a .\bin\$line | Write-Debug
}
Write-Host "Verify digital signature."
foreach ($line in Get-Content .\sign.txt) {
& $signtool verify /pa /q .\bin\$line 2>&1 | Write-Debug
if ($LASTEXITCODE -ne 0)
{
Write-Host ".\bin\$line is not signed. Exit."
exit $LASTEXITCODE
}
Write-Host ".\bin\$line is signed."
}
Write-Host "Verification finished."
Remove-Item -Path .\*.nupkg
$nuget = ".\.nuget\nuget.exe"
& $nuget update /self | Write-Debug
foreach ($line in Get-Content .\nuspec.txt) {
& $nuget pack $line
if ($LASTEXITCODE -ne 0)
{
Write-Host "NuGet package is not generated. Exit."
exit $LASTEXITCODE
}
}
Write-Host "Sign NuGet packages."
& $nuget sign *.nupkg -CertificateSubjectName "Yang Li" -Timestamper http://timestamp.digicert.com | Write-Debug
& $nuget verify -All *.nupkg | Write-Debug
if ($LASTEXITCODE -ne 0)
{
Write-Host "NuGet package is not signed. Exit."
exit $LASTEXITCODE
}
Write-Host "Verification finished."