-
Notifications
You must be signed in to change notification settings - Fork 4
/
Store-Symbols.ps1
53 lines (46 loc) · 1.51 KB
/
Store-Symbols.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
50
51
52
53
param (
[string] $ArchivePath
)
if (-not (Test-Path symstore-venv))
{
python -m venv symstore-venv
if ($LASTEXITCODE -ne 0) {
Write-Error "Command exited with code $LASTEXITCODE"
}
}
$symstoreVersion = "0.3.4"
if (-not (Test-Path symstore-venv\Scripts\symstore.exe) -or -not ((symstore-venv\Scripts\pip show symstore | Select-String '(?<=Version: ).*').Matches.Value -eq $symstoreVersion))
{
symstore-venv\Scripts\pip install symstore==$symstoreVersion
if ($LASTEXITCODE -ne 0) {
Write-Error "Command exited with code $LASTEXITCODE"
}
}
function ProcessDirectory {
param (
[string] $DirectoryPath
)
$artifacts = Get-ChildItem -Recurse -File $DirectoryPath | Where-Object { $_.Extension -in (".dll", ".exe", ".pdb") } | ForEach-Object { Resolve-Path -Relative $_.FullName }
symstore-venv\Scripts\symstore --compress .\SymStore @artifacts
if ($LASTEXITCODE -ne 0) {
Write-Error "Command exited with code $LASTEXITCODE"
}
}
if (Test-Path $ArchivePath -PathType Leaf)
{
try {
New-Item -ItemType Directory temp-symbols
7z x -r $ArchivePath -otemp-symbols *.dll *.exe *.pdb -y
if ($LASTEXITCODE -ne 0) {
Write-Error "Command exited with code $LASTEXITCODE"
}
ProcessDirectory temp-symbols
}
finally {
Remove-Item -Recurse temp-symbols
}
} elseif (Test-Path $ArchivePath -PathType Container) {
ProcessDirectory $ArchivePath
} else {
Write-Error "$ArchivePath does not exist."
}