Skip to content

Commit 82b27d3

Browse files
[main] Update dependencies from dotnet/arcade (dotnet#1448)
* Update dependencies from https://github.com/dotnet/arcade build 20210624.3 Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.21319.2 -> To Version 6.0.0-beta.21324.3 * retain stable sdk * Update dependencies from https://github.com/dotnet/arcade build 20210701.2 Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.21319.2 -> To Version 6.0.0-beta.21351.2 * Update dependencies from https://github.com/dotnet/arcade build 20210707.3 Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.21319.2 -> To Version 6.0.0-beta.21357.3 * Update dependencies from https://github.com/dotnet/arcade build 20210716.1 Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.21319.2 -> To Version 6.0.0-beta.21366.1 * Update dependencies from https://github.com/dotnet/arcade build 20210723.11 Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.21319.2 -> To Version 6.0.0-beta.21373.11 * retain stable sdk Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Brett V. Forsgren <[email protected]>
1 parent 0b69ac2 commit 82b27d3

13 files changed

+453
-66
lines changed

eng/Version.Details.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<ProductDependencies>
44
</ProductDependencies>
55
<ToolsetDependencies>
6-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21319.2">
6+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21373.11">
77
<Uri>https://github.com/dotnet/arcade</Uri>
8-
<Sha>a3377cccde8639089f99107e2ba5df2c8cbe6394</Sha>
8+
<Sha>c6a28c81f96d196338b3ea520bc1e6dc7c440ee2</Sha>
99
</Dependency>
1010
</ToolsetDependencies>
1111
</Dependencies>

eng/common/SetupNugetSources.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,10 @@ if ($dotnet5Source -ne $null) {
158158
AddPackageSource -Sources $sources -SourceName "dotnet5-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password
159159
}
160160

161+
$dotnet6Source = $sources.SelectSingleNode("add[@key='dotnet6']")
162+
if ($dotnet6Source -ne $null) {
163+
AddPackageSource -Sources $sources -SourceName "dotnet6-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password
164+
AddPackageSource -Sources $sources -SourceName "dotnet6-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password
165+
}
166+
161167
$doc.Save($filename)

eng/common/SetupNugetSources.sh

+24
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,30 @@ if [ "$?" == "0" ]; then
129129
PackageSources+=('dotnet5-internal-transport')
130130
fi
131131

132+
# Ensure dotnet6-internal and dotnet6-internal-transport are in the packageSources if the public dotnet6 feeds are present
133+
grep -i "<add key=\"dotnet6\"" $ConfigFile
134+
if [ "$?" == "0" ]; then
135+
grep -i "<add key=\"dotnet6-internal\"" $ConfigFile
136+
if [ "$?" != "0" ]; then
137+
echo "Adding dotnet6-internal to the packageSources."
138+
PackageSourcesNodeFooter="</packageSources>"
139+
PackageSourceTemplate="${TB}<add key=\"dotnet6-internal\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal/nuget/v2\" />"
140+
141+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
142+
fi
143+
PackageSources+=('dotnet6-internal')
144+
145+
grep -i "<add key=\"dotnet6-internal-transport\">" $ConfigFile
146+
if [ "$?" != "0" ]; then
147+
echo "Adding dotnet6-internal-transport to the packageSources."
148+
PackageSourcesNodeFooter="</packageSources>"
149+
PackageSourceTemplate="${TB}<add key=\"dotnet6-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal-transport/nuget/v2\" />"
150+
151+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
152+
fi
153+
PackageSources+=('dotnet6-internal-transport')
154+
fi
155+
132156
# I want things split line by line
133157
PrevIFS=$IFS
134158
IFS=$'\n'

eng/common/cross/build-rootfs.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ __AlpinePackages="alpine-base"
3333
__AlpinePackages+=" build-base"
3434
__AlpinePackages+=" linux-headers"
3535
__AlpinePackagesEdgeCommunity=" lldb-dev"
36-
__AlpinePackagesEdgeMain=" llvm10-libs"
3736
__AlpinePackagesEdgeMain+=" python3"
3837
__AlpinePackagesEdgeMain+=" libedit"
3938

@@ -115,6 +114,8 @@ while :; do
115114
__UbuntuArch=s390x
116115
__UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/"
117116
__UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libunwind8-dev//')
117+
__UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp-dev//')
118+
__UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp5//')
118119
unset __LLDB_Package
119120
;;
120121
x86)
@@ -191,6 +192,8 @@ while :; do
191192
__CodeName=alpine
192193
__UbuntuRepo=
193194
__AlpineVersion=3.9
195+
__AlpinePackagesEdgeMain+=" llvm11-libs"
196+
__AlpinePackagesEdgeMain+=" clang-libs"
194197
;;
195198
alpine3.13)
196199
__CodeName=alpine
@@ -201,6 +204,7 @@ while :; do
201204
__AlpinePackagesEdgeCommunity=
202205
__AlpinePackages+=$__AlpinePackagesEdgeMain
203206
__AlpinePackagesEdgeMain=
207+
__AlpinePackages+=" llvm10-libs"
204208
;;
205209
freebsd11)
206210
__FreeBSDBase="11.3-RELEASE"

eng/common/sdl/configure-sdl-tool.ps1

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
Param(
2+
[string] $GuardianCliLocation,
3+
[string] $WorkingDirectory,
4+
[string] $TargetDirectory,
5+
[string] $GdnFolder,
6+
# The list of Guardian tools to configure. For each object in the array:
7+
# - If the item is a [hashtable], it must contain these entries:
8+
# - Name = The tool name as Guardian knows it.
9+
# - Scenario = (Optional) Scenario-specific name for this configuration entry. It must be unique
10+
# among all tool entries with the same Name.
11+
# - Args = (Optional) Array of Guardian tool configuration args, like '@("Target > C:\temp")'
12+
# - If the item is a [string] $v, it is treated as '@{ Name="$v" }'
13+
[object[]] $ToolsList,
14+
[string] $GuardianLoggerLevel='Standard',
15+
# Optional: Additional params to add to any tool using CredScan.
16+
[string[]] $CrScanAdditionalRunConfigParams,
17+
# Optional: Additional params to add to any tool using PoliCheck.
18+
[string[]] $PoliCheckAdditionalRunConfigParams
19+
)
20+
21+
$ErrorActionPreference = 'Stop'
22+
Set-StrictMode -Version 2.0
23+
$disableConfigureToolsetImport = $true
24+
$global:LASTEXITCODE = 0
25+
26+
try {
27+
# `tools.ps1` checks $ci to perform some actions. Since the SDL
28+
# scripts don't necessarily execute in the same agent that run the
29+
# build.ps1/sh script this variable isn't automatically set.
30+
$ci = $true
31+
. $PSScriptRoot\..\tools.ps1
32+
33+
# Normalize tools list: all in [hashtable] form with defined values for each key.
34+
$ToolsList = $ToolsList |
35+
ForEach-Object {
36+
if ($_ -is [string]) {
37+
$_ = @{ Name = $_ }
38+
}
39+
40+
if (-not ($_['Scenario'])) { $_.Scenario = "" }
41+
if (-not ($_['Args'])) { $_.Args = @() }
42+
$_
43+
}
44+
45+
Write-Host "List of tools to configure:"
46+
$ToolsList | ForEach-Object { $_ | Out-String | Write-Host }
47+
48+
# We store config files in the r directory of .gdn
49+
$gdnConfigPath = Join-Path $GdnFolder 'r'
50+
$ValidPath = Test-Path $GuardianCliLocation
51+
52+
if ($ValidPath -eq $False)
53+
{
54+
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location."
55+
ExitWithExitCode 1
56+
}
57+
58+
foreach ($tool in $ToolsList) {
59+
# Put together the name and scenario to make a unique key.
60+
$toolConfigName = $tool.Name
61+
if ($tool.Scenario) {
62+
$toolConfigName += "_" + $tool.Scenario
63+
}
64+
65+
Write-Host "=== Configuring $toolConfigName..."
66+
67+
$gdnConfigFile = Join-Path $gdnConfigPath "$toolConfigName-configure.gdnconfig"
68+
69+
# For some tools, add default and automatic args.
70+
if ($tool.Name -eq 'credscan') {
71+
if ($targetDirectory) {
72+
$tool.Args += "TargetDirectory < $TargetDirectory"
73+
}
74+
$tool.Args += "OutputType < pre"
75+
$tool.Args += $CrScanAdditionalRunConfigParams
76+
} elseif ($tool.Name -eq 'policheck') {
77+
if ($targetDirectory) {
78+
$tool.Args += "Target < $TargetDirectory"
79+
}
80+
$tool.Args += $PoliCheckAdditionalRunConfigParams
81+
}
82+
83+
# Create variable pointing to the args array directly so we can use splat syntax later.
84+
$toolArgs = $tool.Args
85+
86+
# Configure the tool. If args array is provided or the current tool has some default arguments
87+
# defined, add "--args" and splat each element on the end. Arg format is "{Arg id} < {Value}",
88+
# one per parameter. Doc page for "guardian configure":
89+
# https://dev.azure.com/securitytools/SecurityIntegration/_wiki/wikis/Guardian/1395/configure
90+
Exec-BlockVerbosely {
91+
& $GuardianCliLocation configure `
92+
--working-directory $WorkingDirectory `
93+
--tool $tool.Name `
94+
--output-path $gdnConfigFile `
95+
--logger-level $GuardianLoggerLevel `
96+
--noninteractive `
97+
--force `
98+
$(if ($toolArgs) { "--args" }) @toolArgs
99+
Exit-IfNZEC "Sdl"
100+
}
101+
102+
Write-Host "Created '$toolConfigName' configuration file: $gdnConfigFile"
103+
}
104+
}
105+
catch {
106+
Write-Host $_.ScriptStackTrace
107+
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
108+
ExitWithExitCode 1
109+
}

eng/common/sdl/execute-all-sdl-tools.ps1

+59-12
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,17 @@ Param(
77
[string] $SourceDirectory=$env:BUILD_SOURCESDIRECTORY, # Required: the directory where source files are located
88
[string] $ArtifactsDirectory = (Join-Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY ('artifacts')), # Required: the directory where build artifacts are located
99
[string] $AzureDevOpsAccessToken, # Required: access token for dnceng; should be provided via KeyVault
10-
[string[]] $SourceToolsList, # Optional: list of SDL tools to run on source code
11-
[string[]] $ArtifactToolsList, # Optional: list of SDL tools to run on built artifacts
10+
11+
# Optional: list of SDL tools to run on source code. See 'configure-sdl-tool.ps1' for tools list
12+
# format.
13+
[object[]] $SourceToolsList,
14+
# Optional: list of SDL tools to run on built artifacts. See 'configure-sdl-tool.ps1' for tools
15+
# list format.
16+
[object[]] $ArtifactToolsList,
17+
# Optional: list of SDL tools to run without automatically specifying a target directory. See
18+
# 'configure-sdl-tool.ps1' for tools list format.
19+
[object[]] $CustomToolsList,
20+
1221
[bool] $TsaPublish=$False, # Optional: true will publish results to TSA; only set to true after onboarding to TSA; TSA is the automated framework used to upload test results as bugs.
1322
[string] $TsaBranchName=$env:BUILD_SOURCEBRANCH, # Optional: required for TSA publish; defaults to $(Build.SourceBranchName); TSA is the automated framework used to upload test results as bugs.
1423
[string] $TsaRepositoryName=$env:BUILD_REPOSITORY_NAME, # Optional: TSA repository name; will be generated automatically if not submitted; TSA is the automated framework used to upload test results as bugs.
@@ -63,13 +72,16 @@ try {
6372
ExitWithExitCode 1
6473
}
6574

66-
& $(Join-Path $PSScriptRoot 'init-sdl.ps1') -GuardianCliLocation $guardianCliLocation -Repository $RepoName -BranchName $BranchName -WorkingDirectory $workingDirectory -AzureDevOpsAccessToken $AzureDevOpsAccessToken -GuardianLoggerLevel $GuardianLoggerLevel
75+
Exec-BlockVerbosely {
76+
& $(Join-Path $PSScriptRoot 'init-sdl.ps1') -GuardianCliLocation $guardianCliLocation -Repository $RepoName -BranchName $BranchName -WorkingDirectory $workingDirectory -AzureDevOpsAccessToken $AzureDevOpsAccessToken -GuardianLoggerLevel $GuardianLoggerLevel
77+
}
6778
$gdnFolder = Join-Path $workingDirectory '.gdn'
6879

6980
if ($TsaOnboard) {
7081
if ($TsaCodebaseName -and $TsaNotificationEmail -and $TsaCodebaseAdmin -and $TsaBugAreaPath) {
71-
Write-Host "$guardianCliLocation tsa-onboard --codebase-name `"$TsaCodebaseName`" --notification-alias `"$TsaNotificationEmail`" --codebase-admin `"$TsaCodebaseAdmin`" --instance-url `"$TsaInstanceUrl`" --project-name `"$TsaProjectName`" --area-path `"$TsaBugAreaPath`" --iteration-path `"$TsaIterationPath`" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel"
72-
& $guardianCliLocation tsa-onboard --codebase-name "$TsaCodebaseName" --notification-alias "$TsaNotificationEmail" --codebase-admin "$TsaCodebaseAdmin" --instance-url "$TsaInstanceUrl" --project-name "$TsaProjectName" --area-path "$TsaBugAreaPath" --iteration-path "$TsaIterationPath" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel
82+
Exec-BlockVerbosely {
83+
& $guardianCliLocation tsa-onboard --codebase-name "$TsaCodebaseName" --notification-alias "$TsaNotificationEmail" --codebase-admin "$TsaCodebaseAdmin" --instance-url "$TsaInstanceUrl" --project-name "$TsaProjectName" --area-path "$TsaBugAreaPath" --iteration-path "$TsaIterationPath" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel
84+
}
7385
if ($LASTEXITCODE -ne 0) {
7486
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian tsa-onboard failed with exit code $LASTEXITCODE."
7587
ExitWithExitCode $LASTEXITCODE
@@ -80,20 +92,51 @@ try {
8092
}
8193
}
8294

83-
if ($ArtifactToolsList -and $ArtifactToolsList.Count -gt 0) {
84-
& $(Join-Path $PSScriptRoot 'run-sdl.ps1') -GuardianCliLocation $guardianCliLocation -WorkingDirectory $workingDirectory -TargetDirectory $ArtifactsDirectory -GdnFolder $gdnFolder -ToolsList $ArtifactToolsList -AzureDevOpsAccessToken $AzureDevOpsAccessToken -UpdateBaseline $UpdateBaseline -GuardianLoggerLevel $GuardianLoggerLevel -CrScanAdditionalRunConfigParams $CrScanAdditionalRunConfigParams -PoliCheckAdditionalRunConfigParams $PoliCheckAdditionalRunConfigParams
95+
# Configure a list of tools with a default target directory. Populates the ".gdn/r" directory.
96+
function Configure-ToolsList([object[]] $tools, [string] $targetDirectory) {
97+
if ($tools -and $tools.Count -gt 0) {
98+
Exec-BlockVerbosely {
99+
& $(Join-Path $PSScriptRoot 'configure-sdl-tool.ps1') `
100+
-GuardianCliLocation $guardianCliLocation `
101+
-WorkingDirectory $workingDirectory `
102+
-TargetDirectory $targetDirectory `
103+
-GdnFolder $gdnFolder `
104+
-ToolsList $tools `
105+
-AzureDevOpsAccessToken $AzureDevOpsAccessToken `
106+
-GuardianLoggerLevel $GuardianLoggerLevel `
107+
-CrScanAdditionalRunConfigParams $CrScanAdditionalRunConfigParams `
108+
-PoliCheckAdditionalRunConfigParams $PoliCheckAdditionalRunConfigParams
109+
if ($BreakOnFailure) {
110+
Exit-IfNZEC "Sdl"
111+
}
112+
}
113+
}
85114
}
86-
if ($SourceToolsList -and $SourceToolsList.Count -gt 0) {
87-
& $(Join-Path $PSScriptRoot 'run-sdl.ps1') -GuardianCliLocation $guardianCliLocation -WorkingDirectory $workingDirectory -TargetDirectory $SourceDirectory -GdnFolder $gdnFolder -ToolsList $SourceToolsList -AzureDevOpsAccessToken $AzureDevOpsAccessToken -UpdateBaseline $UpdateBaseline -GuardianLoggerLevel $GuardianLoggerLevel -CrScanAdditionalRunConfigParams $CrScanAdditionalRunConfigParams -PoliCheckAdditionalRunConfigParams $PoliCheckAdditionalRunConfigParams
115+
116+
# Configure Artifact and Source tools with default Target directories.
117+
Configure-ToolsList $ArtifactToolsList $ArtifactsDirectory
118+
Configure-ToolsList $SourceToolsList $SourceDirectory
119+
# Configure custom tools with no default Target directory.
120+
Configure-ToolsList $CustomToolsList $null
121+
122+
# At this point, all tools are configured in the ".gdn" directory. Run them all in a single call.
123+
# (If we used "run" multiple times, each run would overwrite data from earlier runs.)
124+
Exec-BlockVerbosely {
125+
& $(Join-Path $PSScriptRoot 'run-sdl.ps1') `
126+
-GuardianCliLocation $guardianCliLocation `
127+
-WorkingDirectory $workingDirectory `
128+
-UpdateBaseline $UpdateBaseline `
129+
-GdnFolder $gdnFolder
88130
}
89131

90132
if ($TsaPublish) {
91133
if ($TsaBranchName -and $BuildNumber) {
92134
if (-not $TsaRepositoryName) {
93135
$TsaRepositoryName = "$($Repository)-$($BranchName)"
94136
}
95-
Write-Host "$guardianCliLocation tsa-publish --all-tools --repository-name `"$TsaRepositoryName`" --branch-name `"$TsaBranchName`" --build-number `"$BuildNumber`" --codebase-name `"$TsaCodebaseName`" --notification-alias `"$TsaNotificationEmail`" --codebase-admin `"$TsaCodebaseAdmin`" --instance-url `"$TsaInstanceUrl`" --project-name `"$TsaProjectName`" --area-path `"$TsaBugAreaPath`" --iteration-path `"$TsaIterationPath`" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel"
96-
& $guardianCliLocation tsa-publish --all-tools --repository-name "$TsaRepositoryName" --branch-name "$TsaBranchName" --build-number "$BuildNumber" --onboard $True --codebase-name "$TsaCodebaseName" --notification-alias "$TsaNotificationEmail" --codebase-admin "$TsaCodebaseAdmin" --instance-url "$TsaInstanceUrl" --project-name "$TsaProjectName" --area-path "$TsaBugAreaPath" --iteration-path "$TsaIterationPath" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel
137+
Exec-BlockVerbosely {
138+
& $guardianCliLocation tsa-publish --all-tools --repository-name "$TsaRepositoryName" --branch-name "$TsaBranchName" --build-number "$BuildNumber" --onboard $True --codebase-name "$TsaCodebaseName" --notification-alias "$TsaNotificationEmail" --codebase-admin "$TsaCodebaseAdmin" --instance-url "$TsaInstanceUrl" --project-name "$TsaProjectName" --area-path "$TsaBugAreaPath" --iteration-path "$TsaIterationPath" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel
139+
}
97140
if ($LASTEXITCODE -ne 0) {
98141
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian tsa-publish failed with exit code $LASTEXITCODE."
99142
ExitWithExitCode $LASTEXITCODE
@@ -106,7 +149,11 @@ try {
106149

107150
if ($BreakOnFailure) {
108151
Write-Host "Failing the build in case of breaking results..."
109-
& $guardianCliLocation break
152+
Exec-BlockVerbosely {
153+
& $guardianCliLocation break --working-directory $workingDirectory --logger-level $GuardianLoggerLevel
154+
}
155+
} else {
156+
Write-Host "Letting the build pass even if there were breaking results..."
110157
}
111158
}
112159
catch {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# This script looks for each archive file in a directory and extracts it into the target directory.
2+
# For example, the file "$InputPath/bin.tar.gz" extracts to "$ExtractPath/bin.tar.gz.extracted/**".
3+
# Uses the "tar" utility added to Windows 10 / Windows 2019 that supports tar.gz and zip.
4+
param(
5+
# Full path to directory where archives are stored.
6+
[Parameter(Mandatory=$true)][string] $InputPath,
7+
# Full path to directory to extract archives into. May be the same as $InputPath.
8+
[Parameter(Mandatory=$true)][string] $ExtractPath
9+
)
10+
11+
$ErrorActionPreference = 'Stop'
12+
Set-StrictMode -Version 2.0
13+
14+
$disableConfigureToolsetImport = $true
15+
16+
try {
17+
# `tools.ps1` checks $ci to perform some actions. Since the SDL
18+
# scripts don't necessarily execute in the same agent that run the
19+
# build.ps1/sh script this variable isn't automatically set.
20+
$ci = $true
21+
. $PSScriptRoot\..\tools.ps1
22+
23+
Measure-Command {
24+
$jobs = @()
25+
26+
# Find archive files for non-Windows and Windows builds.
27+
$archiveFiles = @(
28+
Get-ChildItem (Join-Path $InputPath "*.tar.gz")
29+
Get-ChildItem (Join-Path $InputPath "*.zip")
30+
)
31+
32+
foreach ($targzFile in $archiveFiles) {
33+
$jobs += Start-Job -ScriptBlock {
34+
$file = $using:targzFile
35+
$fileName = [System.IO.Path]::GetFileName($file)
36+
$extractDir = Join-Path $using:ExtractPath "$fileName.extracted"
37+
38+
New-Item $extractDir -ItemType Directory -Force | Out-Null
39+
40+
Write-Host "Extracting '$file' to '$extractDir'..."
41+
42+
# Pipe errors to stdout to prevent PowerShell detecting them and quitting the job early.
43+
# This type of quit skips the catch, so we wouldn't be able to tell which file triggered the
44+
# error. Save output so it can be stored in the exception string along with context.
45+
$output = tar -xf $file -C $extractDir 2>&1
46+
# Handle NZEC manually rather than using Exit-IfNZEC: we are in a background job, so we
47+
# don't have access to the outer scope.
48+
if ($LASTEXITCODE -ne 0) {
49+
throw "Error extracting '$file': non-zero exit code ($LASTEXITCODE). Output: '$output'"
50+
}
51+
52+
Write-Host "Extracted to $extractDir"
53+
}
54+
}
55+
56+
Receive-Job $jobs -Wait
57+
}
58+
}
59+
catch {
60+
Write-Host $_
61+
Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
62+
ExitWithExitCode 1
63+
}

0 commit comments

Comments
 (0)