Skip to content

Commit 432d25a

Browse files
committed
Skip bad global.json files
1 parent 235c4ce commit 432d25a

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

azure-pipelines.yml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,36 +92,42 @@ jobs:
9292
$installDir = "$(Agent.ToolsDirectory)/dotnet"
9393
9494
ls -Recurse -Include global.json | %{
95-
Write-Host "Processing $_"
96-
$v = $_ | Get-Content -Raw | ConvertFrom-Json | %{ if ($_.tools.dotnet) {$_.tools.dotnet} else {$_.sdk.version} }
97-
if (-not $v)
98-
{
99-
Write-Host "No version found in $_"
100-
return
101-
}
102-
$isSensibleVersion = $v.Split('.')[0] -as [int] -le 30
103-
if (-not $isSensibleVersion)
104-
{
105-
Write-Host "Skipping bogus version $v"
106-
return
107-
}
95+
try {
96+
Write-Host "Processing $_"
97+
$v = $_ | Get-Content -Raw | ConvertFrom-Json | %{ if ($_.tools.dotnet) {$_.tools.dotnet} else {$_.sdk.version} }
98+
if (-not $v)
99+
{
100+
Write-Host "No version found in $_"
101+
return
102+
}
103+
$isSensibleVersion = $v.Split('.')[0] -as [int] -le 30
104+
if (-not $isSensibleVersion)
105+
{
106+
Write-Host "Skipping bogus version $v"
107+
return
108+
}
108109
109-
Write-Host "Installing .NET CLI version $v"
110-
try
111-
{
112-
& $installScript -Version $v -InstallDir $installDir -NoPath
113-
}
114-
catch
115-
{
110+
Write-Host "Installing .NET CLI version $v"
116111
try
117112
{
118-
& $installScript -Version $v -InstallDir $installDir -NoPath -AzureFeed https://dotnetbuilds.azureedge.net/public
113+
& $installScript -Version $v -InstallDir $installDir -NoPath
119114
}
120115
catch
121116
{
122-
throw "Unable to install Version $v"
117+
try
118+
{
119+
& $installScript -Version $v -InstallDir $installDir -NoPath -AzureFeed https://dotnetbuilds.azureedge.net/public
120+
}
121+
catch
122+
{
123+
throw "Unable to install Version $v"
124+
}
123125
}
124126
}
127+
catch
128+
{
129+
Write-Host "Skipping bad json file."
130+
}
125131
}
126132
displayName: 'Install Required Versions of .NET Core'
127133

0 commit comments

Comments
 (0)