@@ -97,13 +97,13 @@ function Initialize-DirectoryStructure {
97
97
Packages = Join-Path $BaseDirectory " signed\packages"
98
98
}
99
99
100
- Write-Host " `n Creating directory structure..."
100
+ Write-Debug " `n Creating directory structure..."
101
101
# Only create the directories we'll manage
102
102
$directories.Keys | Where-Object { $_ -ne ' WorkingDir' } | ForEach-Object {
103
103
$dir = $directories [$_ ]
104
104
if (-not (Test-Path $dir )) {
105
105
New-Item - ItemType Directory - Path $dir - Force | Out-Null
106
- Write-Host " ✓ Created: $dir "
106
+ Write-Debug " ✓ Created: $dir "
107
107
}
108
108
}
109
109
@@ -120,25 +120,23 @@ function Test-GithubAttestation {
120
120
[string ]$RepoName
121
121
)
122
122
123
- Write-Host " 🔐 Verifying attestation for: $FilePath " - ForegroundColor Gray
123
+ # Get the parent directory name and the file name
124
+ $fileName = (Get-ChildItem $FilePath ).Name
125
+
126
+ Write-Host " 🔐 Verifying attestation for: ..$parentDir \$fileName " - ForegroundColor Gray
124
127
125
128
try {
126
- # Check if gh CLI is available
127
- if (-not (Get-Command gh - ErrorAction SilentlyContinue)) {
128
- throw " GitHub CLI (gh) is not installed or not in PATH"
129
- }
130
-
131
129
$output = gh attestation verify $FilePath -- repo $RepoName 2>&1
132
130
if ($LASTEXITCODE -ne 0 ) {
133
131
Write-Host $output - ForegroundColor Red
134
132
throw $output # This will trigger the catch block
135
133
}
136
134
137
- Write-Host " ✅ Attestation verified " - ForegroundColor Green
135
+ Write-Host " ✅ Verified " - ForegroundColor Green
138
136
return $true
139
137
}
140
138
catch {
141
- Write-Host " ❌ Attestation verification failed: $_ " - ForegroundColor Red
139
+ Write-Host " ❌ Verification failed: $_ " - ForegroundColor Red
142
140
return $false
143
141
}
144
142
}
@@ -160,6 +158,8 @@ How to use:
160
158
> . \.Yubico.NET.SDK\build\sign.ps1
161
159
4. The script can be invoked by following the examples below.
162
160
161
+ Set $DebugPreference = "Continue" for verbose output
162
+
163
163
. PARAMETER Thumbprint
164
164
The thumbprint of the signing certificate stored on the smart card.
165
165
@@ -241,6 +241,11 @@ function Invoke-NuGetPackageSigning {
241
241
}
242
242
Write-Host " ✓ NuGet found at: $NuGetPath "
243
243
244
+ if (-not (Get-Command gh - ErrorAction SilentlyContinue)) {
245
+ throw " GitHub CLI installed or not found in PATH"
246
+ }
247
+ Write-Host " ✓ GitHub CLI found at: $NuGetPath "
248
+
244
249
# Verify certificate is available and log details
245
250
$cert = Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.Thumbprint -eq $Thumbprint }
246
251
if (-not $cert ) {
@@ -304,7 +309,7 @@ function Invoke-NuGetPackageSigning {
304
309
Write-Host " Extracting to: $extractPath "
305
310
Expand-Archive - Path $package.FullName - DestinationPath $extractPath - Force
306
311
307
- Write-Host " Cleaning package structure"
312
+ Write-Debug " Cleaning package structure"
308
313
Get-ChildItem - Path $extractPath - Recurse - Include " _rels" , " package" | Remove-Item - Force - Recurse
309
314
Get-ChildItem - Path $extractPath - Recurse - Filter ' [Content_Types].xml' | Remove-Item - Force
310
315
@@ -318,11 +323,16 @@ function Invoke-NuGetPackageSigning {
318
323
Sign- SingleFile - FilePath $dll.FullName - Thumbprint $Thumbprint - SignToolPath $SignToolPath - TimestampServer $TimestampServer
319
324
}
320
325
321
- Write-Host " Repacking signed content ..."
326
+ Write-Host " Repacking assemblies ..."
322
327
Get-ChildItem - Path $extractPath - Recurse - Filter " *.nuspec" |
323
328
ForEach-Object {
324
329
Write-Host " Packing: $ ( $_.Name ) "
325
- & $NuGetPath pack $_.FullName - OutputDirectory $directories.Packages
330
+ $output = & $NuGetPath pack $_.FullName - OutputDirectory $directories.Packages 2>&1
331
+
332
+ if ($LASTEXITCODE -ne 0 ) {
333
+ $output | ForEach-Object { Write-Host $_ }
334
+ throw " Signing failed for file: $FilePath "
335
+ }
326
336
}
327
337
}
328
338
@@ -345,7 +355,13 @@ function Invoke-NuGetPackageSigning {
345
355
" -Timestamper" , $TimestampServer ,
346
356
" -NonInteractive"
347
357
)
348
- & $NuGetPath @nugetSignParams
358
+
359
+ $output = & $NuGetPath @nugetSignParams 2>&1
360
+
361
+ if ($LASTEXITCODE -ne 0 ) {
362
+ $output | ForEach-Object { Write-Host $_ }
363
+ throw " Signing failed for file: $FilePath "
364
+ }
349
365
}
350
366
351
367
# Print summary of signed packages
@@ -363,7 +379,9 @@ function Invoke-NuGetPackageSigning {
363
379
}
364
380
365
381
Write-Host " `n ✨ Package signing process completed successfully! ✨" - ForegroundColor Green
366
- return $directories.Packages
382
+ Write-Host " ➡️ Locate your signed packages here: $ ( $directories.Packages ) " - ForegroundColor Yellow
383
+
384
+ return
367
385
}
368
386
catch {
369
387
Write-Host " `n ❌ Error occurred:" - ForegroundColor Red
0 commit comments