Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 2bc2374

Browse files
dougbuSteveSandersonMS
authored andcommitted
Sync shared code from arcade
1 parent 07e61e0 commit 2bc2374

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

eng/common/tools.ps1

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ function InstallDotNet([string] $dotnetRoot,
287287
[string] $runtimeSourceFeedKey = '',
288288
[switch] $noPath) {
289289

290+
$dotnetVersionLabel = "'sdk v$version'"
291+
292+
if ($runtime -ne '' -and $runtime -ne 'sdk') {
293+
$runtimePath = $dotnetRoot
294+
$runtimePath = $runtimePath + "\shared"
295+
if ($runtime -eq "dotnet") { $runtimePath = $runtimePath + "\Microsoft.NETCore.App" }
296+
if ($runtime -eq "aspnetcore") { $runtimePath = $runtimePath + "\Microsoft.AspNetCore.App" }
297+
if ($runtime -eq "windowsdesktop") { $runtimePath = $runtimePath + "\Microsoft.WindowsDesktop.App" }
298+
$runtimePath = $runtimePath + "\" + $version
299+
300+
$dotnetVersionLabel = "runtime toolset '$runtime/$architecture v$version'"
301+
302+
if (Test-Path $runtimePath) {
303+
Write-Host " Runtime toolset '$runtime/$architecture v$version' already installed."
304+
$installSuccess = $true
305+
Exit
306+
}
307+
}
308+
290309
$installScript = GetDotNetInstallScript $dotnetRoot
291310
$installParameters = @{
292311
Version = $version
@@ -323,18 +342,18 @@ function InstallDotNet([string] $dotnetRoot,
323342
} else {
324343
$location = "public location";
325344
}
326-
Write-Host "Attempting to install dotnet from $location."
345+
Write-Host " Attempting to install $dotnetVersionLabel from $location."
327346
try {
328347
& $installScript @variation
329348
$installSuccess = $true
330349
break
331350
}
332351
catch {
333-
Write-Host "Failed to install dotnet from $location."
352+
Write-Host " Failed to install $dotnetVersionLabel from $location."
334353
}
335354
}
336355
if (-not $installSuccess) {
337-
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Failed to install dotnet from any of the specified locations."
356+
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Failed to install $dotnetVersionLabel from any of the specified locations."
338357
ExitWithExitCode 1
339358
}
340359
}
@@ -399,7 +418,8 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
399418
# Locate Visual Studio installation or download x-copy msbuild.
400419
$vsInfo = LocateVisualStudio $vsRequirements
401420
if ($vsInfo -ne $null) {
402-
$vsInstallDir = $vsInfo.installationPath
421+
# Ensure vsInstallDir has a trailing slash
422+
$vsInstallDir = Join-Path $vsInfo.installationPath "\"
403423
$vsMajorVersion = $vsInfo.installationVersion.Split('.')[0]
404424

405425
InitializeVisualStudioEnvironmentVariables $vsInstallDir $vsMajorVersion

eng/common/tools.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,35 @@ function InstallDotNetSdk {
184184
function InstallDotNet {
185185
local root=$1
186186
local version=$2
187+
local runtime=$4
188+
189+
local dotnetVersionLabel="'$runtime v$version'"
190+
if [[ -n "${4:-}" ]] && [ "$4" != 'sdk' ]; then
191+
runtimePath="$root"
192+
runtimePath="$runtimePath/shared"
193+
case "$runtime" in
194+
dotnet)
195+
runtimePath="$runtimePath/Microsoft.NETCore.App"
196+
;;
197+
aspnetcore)
198+
runtimePath="$runtimePath/Microsoft.AspNetCore.App"
199+
;;
200+
windowsdesktop)
201+
runtimePath="$runtimePath/Microsoft.WindowsDesktop.App"
202+
;;
203+
*)
204+
;;
205+
esac
206+
runtimePath="$runtimePath/$version"
207+
208+
dotnetVersionLabel="runtime toolset '$runtime/$architecture v$version'"
209+
210+
if [ -d "$runtimePath" ]; then
211+
echo " Runtime toolset '$runtime/$architecture v$version' already installed."
212+
local installSuccess=1
213+
return
214+
fi
215+
fi
187216

188217
GetDotNetInstallScript "$root"
189218
local install_script=$_GetDotNetInstallScript
@@ -228,17 +257,17 @@ function InstallDotNet {
228257
for variationName in "${variations[@]}"; do
229258
local name="$variationName[@]"
230259
local variation=("${!name}")
231-
echo "Attempting to install dotnet from $variationName."
260+
echo " Attempting to install $dotnetVersionLabel from $variationName."
232261
bash "$install_script" "${variation[@]}" && installSuccess=1
233262
if [[ "$installSuccess" -eq 1 ]]; then
234263
break
235264
fi
236265

237-
echo "Failed to install dotnet from $variationName."
266+
echo " Failed to install $dotnetVersionLabel from $variationName."
238267
done
239268

240269
if [[ "$installSuccess" -eq 0 ]]; then
241-
Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to install dotnet SDK from any of the specified locations."
270+
Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to install $dotnetVersionLabel from any of the specified locations."
242271
ExitWithExitCode 1
243272
fi
244273
}

0 commit comments

Comments
 (0)