2 [Parameter
(Mandatory
=$true)][string
] $InputPath, # Full path to directory where artifact packages are stored
3 [Parameter
(Mandatory
=$true)][string
] $ExtractPath # Full path to directory where the packages will be extracted
6 $ErrorActionPreference = "Stop"
7 Set-StrictMode
-Version
2.0
9 # `tools.ps1` checks $ci to perform some actions. Since the post-build
10 # scripts don't necessarily execute in the same agent that run the
11 # build.ps1/sh script this variable isn't automatically set.
13 $disableConfigureToolsetImport = "true"
14 . $PSScriptRoot\
..\tools
.ps1
18 [string
] $PackagePath # Full path to a NuGet package
21 if (!(Test-Path $PackagePath)) {
22 Write-PipelineTaskError
"Input file does not exist: $PackagePath"
26 $RelevantExtensions = @
(".dll", ".exe", ".pdb")
27 Write-Host -NoNewLine
"Extracting" ([System
.IO
.Path
]::GetFileName
($PackagePath)) "... "
29 $PackageId = [System
.IO
.Path
]::GetFileNameWithoutExtension
($PackagePath)
30 $ExtractPath = Join-Path -Path
$using:ExtractPath
-ChildPath
$PackageId
32 Add-Type
-AssemblyName System
.IO
.Compression
.FileSystem
34 [System
.IO
.Directory
]::CreateDirectory
($ExtractPath);
37 $zip = [System
.IO
.Compression
.ZipFile
]::OpenRead
($PackagePath)
40 Where-Object {$RelevantExtensions -contains
[System
.IO
.Path
]::GetExtension
($_.Name
)} |
42 $TargetFile = Join-Path -Path
$ExtractPath -ChildPath
$_.Name
44 [System
.IO
.Compression
.ZipFileExtensions
]::ExtractToFile
($_, $TargetFile, $true)
54 function ExtractArtifacts
{
55 if (!(Test-Path $InputPath)) {
56 Write-Host "Input Path does not exist: $InputPath"
60 Get-ChildItem "$InputPath\*.nupkg" |
62 $Jobs += Start-Job
-ScriptBlock
$ExtractPackage -ArgumentList
$_.FullName
65 foreach ($Job in $Jobs) {
66 Wait-Job
-Id
$Job.Id
| Receive-Job
71 Measure-Command { ExtractArtifacts
}
75 Write-Host $_.Exception
76 Write-Host $_.ScriptStackTrace