|
| 1 | +param ( |
| 2 | + [string] $ArchivePath |
| 3 | +) |
| 4 | + |
| 5 | +if (-not (Test-Path symstore-venv)) |
| 6 | +{ |
| 7 | + python -m venv symstore-venv |
| 8 | + if ($LASTEXITCODE -ne 0) { |
| 9 | + Write-Error "Command exited with code $LASTEXITCODE" |
| 10 | + } |
| 11 | +} |
| 12 | +$symstoreVersion = "0.3.4" |
| 13 | +if (-not (Test-Path symstore-venv\Scripts\symstore.exe) -or -not ((symstore-venv\Scripts\pip show symstore | Select-String '(?<=Version: ).*').Matches.Value -eq $symstoreVersion)) |
| 14 | +{ |
| 15 | + symstore-venv\Scripts\pip install symstore==$symstoreVersion |
| 16 | + if ($LASTEXITCODE -ne 0) { |
| 17 | + Write-Error "Command exited with code $LASTEXITCODE" |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +function ProcessDirectory { |
| 22 | + param ( |
| 23 | + [string] $DirectoryPath |
| 24 | + ) |
| 25 | + |
| 26 | + $artifacts = Get-ChildItem -Recurse -File $DirectoryPath | Where-Object { $_.Extension -in (".dll", ".exe", ".pdb") } | ForEach-Object { Resolve-Path -Relative $_.FullName } |
| 27 | + |
| 28 | + symstore-venv\Scripts\symstore --compress .\SymStore @artifacts |
| 29 | + if ($LASTEXITCODE -ne 0) { |
| 30 | + Write-Error "Command exited with code $LASTEXITCODE" |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +if (Test-Path $ArchivePath -PathType Leaf) |
| 35 | +{ |
| 36 | + try { |
| 37 | + New-Item -ItemType Directory temp-symbols |
| 38 | + |
| 39 | + 7z x -r $ArchivePath -otemp-symbols *.dll *.exe *.pdb -y |
| 40 | + if ($LASTEXITCODE -ne 0) { |
| 41 | + Write-Error "Command exited with code $LASTEXITCODE" |
| 42 | + } |
| 43 | + |
| 44 | + ProcessDirectory temp-symbols |
| 45 | + } |
| 46 | + finally { |
| 47 | + Remove-Item -Recurse temp-symbols |
| 48 | + } |
| 49 | +} elseif (Test-Path $ArchivePath -PathType Container) { |
| 50 | + ProcessDirectory $ArchivePath |
| 51 | +} else { |
| 52 | + Write-Error "$ArchivePath does not exist." |
| 53 | +} |
0 commit comments