Skip to content

Commit

Permalink
Fixed signing steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Aug 6, 2024
1 parent b676c39 commit 90ad0a6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 54 deletions.
1 change: 0 additions & 1 deletion cert.txt

This file was deleted.

2 changes: 1 addition & 1 deletion dist.nuget.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ del *.nupkg
del *.snupkg
call build.release.bat
IF %ERRORLEVEL% NEQ 0 exit /b 1
call sign3.bat
powershell -ExecutionPolicy Bypass -file sign3.ps1
IF %ERRORLEVEL% NEQ 0 exit /b 1
copy SharpSnmpLib\bin\Release\*.nupkg .
copy SharpSnmpLib\bin\Release\*.snupkg .
Expand Down
23 changes: 3 additions & 20 deletions release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,11 @@ catch
{
Write-Host "MSBuild doesn't exist. Use VSSetup instead."

Install-Module VSSetup -Scope CurrentUser -Force
Update-Module VSSetup
$instance = Get-VSSetupInstance -All -Prerelease | Select-VSSetupInstance -Latest
$installDir = $instance.installationPath
Write-Host "Found VS in " + $installDir
$msBuild = $installDir + '\MSBuild\Current\Bin\MSBuild.exe'
$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
if (![System.IO.File]::Exists($msBuild))
{
$msBuild = $installDir + '\MSBuild\15.0\Bin\MSBuild.exe'
if (![System.IO.File]::Exists($msBuild))
{
Write-Host "MSBuild doesn't exist. Exit."
exit 1
}
else
{
Write-Host "Likely on Windows with VS2017."
}
}
else
{
Write-Host "Likely on Windows with VS2019 or VS2022."
Write-Host "MSBuild doesn't exist. Exit."
exit 1
}

Write-Host "MSBuild found. Compile the projects."
Expand Down
19 changes: 6 additions & 13 deletions sign.assembly.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
$file = Join-Path $PSScriptRoot "cert.txt"
if (-not (Test-Path $file))
{
Write-Host "No certificate specified. Exit."
exit 0
}
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1

$cert = Get-Content -Path $file -TotalCount 1
$foundCert = Test-Certificate -Cert $cert -User
if(!$foundCert)
{
Write-Host "Certificate doesn't exist. Exit."
exit 0
if ($cert -eq $null) {
Write-Host "No code signing certificate found in MY store. Exit."
exit 1
}

$signtool="C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64\signtool.exe"
$signtool = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "signtool.exe" | Select-Object -First 1 -ExpandProperty FullName
Write-host "Signtool path: $signtool"
if (Test-Path $signtool) {
Write-Output "sign the assembly"
& $signtool sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /a $args[0]
Expand Down
19 changes: 0 additions & 19 deletions sign3.bat

This file was deleted.

24 changes: 24 additions & 0 deletions sign3.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$signtool = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "signtool.exe" | Select-Object -First 1 -ExpandProperty FullName
Write-host "Signtool path: $signtool"
if (Test-Path $signtool) {
New-Item -ItemType Directory -Path ".\SharpSnmpLib\bin\Release" -Force | Out-Null
Set-Location -Path ".\SharpSnmpLib\bin\Release"
Get-ChildItem -Recurse -Include *.exe, *.dll | ForEach-Object {
& $signtool verify /pa /q $_.FullName
if ($LASTEXITCODE -ne 0) {
Read-Host "Press Enter to continue..."
}
}
Set-Location -Path "..\..\.."
New-Item -ItemType Directory -Path ".\SharpSnmpLib.BouncyCastle\bin\Release" -Force | Out-Null
Set-Location -Path ".\SharpSnmpLib.BouncyCastle\bin\Release"
Get-ChildItem -Recurse -Include *.exe, *.dll | ForEach-Object {
& $signtool verify /pa /q $_.FullName
if ($LASTEXITCODE -ne 0) {
Read-Host "Press Enter to continue..."
}
}
Set-Location -Path "..\..\.."
}

Exit 0

0 comments on commit 90ad0a6

Please sign in to comment.