Skip to content

Commit 0721c3b

Browse files
authored
Pull publishdata from the branch being published
1 parent 8edc5e4 commit 0721c3b

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

eng/build-utils.ps1

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $ErrorActionPreference="Stop"
88

99
$VSSetupDir = Join-Path $ArtifactsDir "VSSetup\$configuration"
1010
$PackagesDir = Join-Path $ArtifactsDir "packages\$configuration"
11-
$PublishDataUrl = "https://raw.githubusercontent.com/dotnet/roslyn/main/eng/config/PublishData.json"
11+
$PublishDataUrlTemplate = "https://raw.githubusercontent.com/dotnet/roslyn/{0}/eng/config/PublishData.json"
1212

1313
$binaryLog = if (Test-Path variable:binaryLog) { $binaryLog } else { $false }
1414
$nodeReuse = if (Test-Path variable:nodeReuse) { $nodeReuse } else { $false }
@@ -22,19 +22,21 @@ function GetProjectOutputBinary([string]$fileName, [string]$projectName = "", [s
2222
return Join-Path $ArtifactsDir "bin\$projectName\$configuration\$tfm\$ridDir$publishDir$fileName"
2323
}
2424

25-
function GetPublishData() {
25+
function GetPublishData([string]$branchName = "main") {
2626
if (Test-Path variable:global:_PublishData) {
2727
return $global:_PublishData
2828
}
2929

30+
$PublishDataUrl = $PublishDataUrlTemplate -f $branchName
31+
3032
Write-Host "Downloading $PublishDataUrl"
3133
$content = (Invoke-WebRequest -Uri $PublishDataUrl -UseBasicParsing).Content
3234

3335
return $global:_PublishData = ConvertFrom-Json $content
3436
}
3537

3638
function GetBranchPublishData([string]$branchName) {
37-
$data = GetPublishData
39+
$data = GetPublishData $branchName
3840

3941
if (Get-Member -InputObject $data.branches -Name $branchName) {
4042
return $data.branches.$branchName
@@ -74,8 +76,8 @@ function Exec-CommandCore([string]$command, [string]$commandArgs, [switch]$useCo
7476

7577
if ($useConsole) {
7678
$exitCode = Exec-Process $command $commandArgs
77-
if ($exitCode -ne 0) {
78-
throw "Command failed to execute with exit code $($exitCode): $command $commandArgs"
79+
if ($exitCode -ne 0) {
80+
throw "Command failed to execute with exit code $($exitCode): $command $commandArgs"
7981
}
8082
return
8183
}
@@ -95,24 +97,24 @@ function Exec-CommandCore([string]$command, [string]$commandArgs, [switch]$useCo
9597

9698
$finished = $false
9799
try {
98-
# The OutputDataReceived event doesn't fire as events are sent by the
100+
# The OutputDataReceived event doesn't fire as events are sent by the
99101
# process in powershell. Possibly due to subtlties of how Powershell
100102
# manages the thread pool that I'm not aware of. Using blocking
101-
# reading here as an alternative which is fine since this blocks
103+
# reading here as an alternative which is fine since this blocks
102104
# on completion already.
103105
$out = $process.StandardOutput
104106
while (-not $out.EndOfStream) {
105107
$line = $out.ReadLine()
106108
Write-Output $line
107109
}
108110

109-
while (-not $process.WaitForExit(100)) {
111+
while (-not $process.WaitForExit(100)) {
110112
# Non-blocking loop done to allow ctr-c interrupts
111113
}
112114

113115
$finished = $true
114-
if ($process.ExitCode -ne 0) {
115-
throw "Command failed to execute with exit code $($process.ExitCode): $command $commandArgs"
116+
if ($process.ExitCode -ne 0) {
117+
throw "Command failed to execute with exit code $($process.ExitCode): $command $commandArgs"
116118
}
117119
}
118120
finally {
@@ -124,15 +126,15 @@ function Exec-CommandCore([string]$command, [string]$commandArgs, [switch]$useCo
124126
}
125127
}
126128

127-
# Handy function for executing a windows command which needs to go through
128-
# windows command line parsing.
129+
# Handy function for executing a windows command which needs to go through
130+
# windows command line parsing.
129131
#
130-
# Use this when the command arguments are stored in a variable. Particularly
132+
# Use this when the command arguments are stored in a variable. Particularly
131133
# when the variable needs reparsing by the windows command line. Example:
132134
#
133135
# $args = "/p:ManualBuild=true Test.proj"
134136
# Exec-Command $msbuild $args
135-
#
137+
#
136138
# The -useConsole argument controls if the process should re-use the current
137139
# console for output or return output as a string
138140
function Exec-Command([string]$command, [string]$commandArgs, [switch]$useConsole = $false, [switch]$echoCommand = $true) {
@@ -142,7 +144,7 @@ function Exec-Command([string]$command, [string]$commandArgs, [switch]$useConsol
142144
Exec-CommandCore -command $command -commandArgs $commandArgs -useConsole:$useConsole -echoCommand:$echoCommand
143145
}
144146

145-
# Handy function for executing a dotnet command without having to track down the
147+
# Handy function for executing a dotnet command without having to track down the
146148
# proper dotnet executable or ensure it's on the path.
147149
function Exec-DotNet([string]$commandArgs = "", [switch]$useConsole = $true, [switch]$echoCommand = $true) {
148150
if ($args -ne "") {
@@ -236,7 +238,7 @@ function Get-PackagesDir() {
236238
return $d
237239
}
238240

239-
# Locate the directory of a specific NuGet package which is restored via our main
241+
# Locate the directory of a specific NuGet package which is restored via our main
240242
# toolset values.
241243
function Get-PackageDir([string]$name, [string]$version = "") {
242244
if ($version -eq "") {

0 commit comments

Comments
 (0)