-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathsignPackages.ps1
49 lines (43 loc) · 1.43 KB
/
signPackages.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
param(
[string]$ConfigPath,
[string]$UserName,
[string]$Password,
[string]$ProductName,
[string]$ProductDescription,
[string]$ProductUrl,
[string]$DirectoryPath
)
# Logging the received parameters (optional, for debugging)
Write-Output "Using configuration: $ConfigPath"
Write-Output "Product Name: $ProductName"
Write-Output "Product Description: $ProductDescription"
Write-Output "Product URL: $ProductUrl"
Write-Output "Directory for signing: $DirectoryPath"
# Validate that the directory exists
if (-Not (Test-Path $DirectoryPath)) {
Write-Error "Directory does not exist: $DirectoryPath"
exit 1
}
# Loop over each .nupkg and .snupkg file in the directory
Get-ChildItem -Path $DirectoryPath -Include *.nupkg,*.snupkg -Recurse | ForEach-Object {
$filePath = $_.FullName
Write-Output "Signing file: $filePath"
# Define the command and parameters
$command = "SignClient"
$arguments = "--config", $ConfigPath,
"-r", $UserName,
"-s", $Password,
"-n", $ProductName,
"-d", $ProductDescription,
"-u", $ProductUrl,
"-i", $filePath
# Execute SignClient and capture the output directly
try {
SignClient sign $arguments
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to sign $filePath."
}
} catch {
Write-Error "An error occurred: $_"
}
}