Skip to content

Commit 90ad0a6

Browse files
committed
Fixed signing steps.
1 parent b676c39 commit 90ad0a6

File tree

6 files changed

+34
-54
lines changed

6 files changed

+34
-54
lines changed

cert.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist.nuget.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ del *.nupkg
44
del *.snupkg
55
call build.release.bat
66
IF %ERRORLEVEL% NEQ 0 exit /b 1
7-
call sign3.bat
7+
powershell -ExecutionPolicy Bypass -file sign3.ps1
88
IF %ERRORLEVEL% NEQ 0 exit /b 1
99
copy SharpSnmpLib\bin\Release\*.nupkg .
1010
copy SharpSnmpLib\bin\Release\*.snupkg .

release.ps1

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,11 @@ catch
1717
{
1818
Write-Host "MSBuild doesn't exist. Use VSSetup instead."
1919

20-
Install-Module VSSetup -Scope CurrentUser -Force
21-
Update-Module VSSetup
22-
$instance = Get-VSSetupInstance -All -Prerelease | Select-VSSetupInstance -Latest
23-
$installDir = $instance.installationPath
24-
Write-Host "Found VS in " + $installDir
25-
$msBuild = $installDir + '\MSBuild\Current\Bin\MSBuild.exe'
20+
$msbuild = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe -products * -nologo | select-object -first 1
2621
if (![System.IO.File]::Exists($msBuild))
2722
{
28-
$msBuild = $installDir + '\MSBuild\15.0\Bin\MSBuild.exe'
29-
if (![System.IO.File]::Exists($msBuild))
30-
{
31-
Write-Host "MSBuild doesn't exist. Exit."
32-
exit 1
33-
}
34-
else
35-
{
36-
Write-Host "Likely on Windows with VS2017."
37-
}
38-
}
39-
else
40-
{
41-
Write-Host "Likely on Windows with VS2019 or VS2022."
23+
Write-Host "MSBuild doesn't exist. Exit."
24+
exit 1
4225
}
4326

4427
Write-Host "MSBuild found. Compile the projects."

sign.assembly.ps1

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
$file = Join-Path $PSScriptRoot "cert.txt"
2-
if (-not (Test-Path $file))
3-
{
4-
Write-Host "No certificate specified. Exit."
5-
exit 0
6-
}
1+
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
72

8-
$cert = Get-Content -Path $file -TotalCount 1
9-
$foundCert = Test-Certificate -Cert $cert -User
10-
if(!$foundCert)
11-
{
12-
Write-Host "Certificate doesn't exist. Exit."
13-
exit 0
3+
if ($cert -eq $null) {
4+
Write-Host "No code signing certificate found in MY store. Exit."
5+
exit 1
146
}
157

16-
$signtool="C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64\signtool.exe"
8+
$signtool = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "signtool.exe" | Select-Object -First 1 -ExpandProperty FullName
9+
Write-host "Signtool path: $signtool"
1710
if (Test-Path $signtool) {
1811
Write-Output "sign the assembly"
1912
& $signtool sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /a $args[0]

sign3.bat

Lines changed: 0 additions & 19 deletions
This file was deleted.

sign3.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$signtool = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "signtool.exe" | Select-Object -First 1 -ExpandProperty FullName
2+
Write-host "Signtool path: $signtool"
3+
if (Test-Path $signtool) {
4+
New-Item -ItemType Directory -Path ".\SharpSnmpLib\bin\Release" -Force | Out-Null
5+
Set-Location -Path ".\SharpSnmpLib\bin\Release"
6+
Get-ChildItem -Recurse -Include *.exe, *.dll | ForEach-Object {
7+
& $signtool verify /pa /q $_.FullName
8+
if ($LASTEXITCODE -ne 0) {
9+
Read-Host "Press Enter to continue..."
10+
}
11+
}
12+
Set-Location -Path "..\..\.."
13+
New-Item -ItemType Directory -Path ".\SharpSnmpLib.BouncyCastle\bin\Release" -Force | Out-Null
14+
Set-Location -Path ".\SharpSnmpLib.BouncyCastle\bin\Release"
15+
Get-ChildItem -Recurse -Include *.exe, *.dll | ForEach-Object {
16+
& $signtool verify /pa /q $_.FullName
17+
if ($LASTEXITCODE -ne 0) {
18+
Read-Host "Press Enter to continue..."
19+
}
20+
}
21+
Set-Location -Path "..\..\.."
22+
}
23+
24+
Exit 0

0 commit comments

Comments
 (0)