Skip to content

Commit

Permalink
Merge pull request #11315 from dependabot/dev/brettfo/nuget-sdk-null-…
Browse files Browse the repository at this point in the history
…check

do null check before attempting to install sdk
  • Loading branch information
randhircs authored Jan 16, 2025
2 parents 2fd554a + 6754717 commit 167798e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nuget/updater/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ function Install-Sdks([string]$jobFilePath, [string]$repoContentsPath, [string]$
foreach ($globalJsonRelativePath in $globalJsonRelativePaths) {
$globalJsonPath = "$rootDir/$globalJsonRelativePath"
$globalJson = Get-Content $globalJsonPath | ConvertFrom-Json
if ("sdk" -notin $globalJson.PSobject.Properties.Name) {
continue
}
if ("version" -notin $globalJson.sdk.PSobject.Properties.Name) {
continue
}

$sdkVersion = $globalJson.sdk.version
if (-Not ($sdkVersion -in $installedSdks)) {
if (($Null -ne $sdkVersion) -And (-Not ($sdkVersion -in $installedSdks))) {
$installedSdks += $sdkVersion
Write-Host "Installing SDK $sdkVersion as specified in $globalJsonRelativePath"
& $dotnetInstallScriptPath --version $sdkVersion --install-dir $dotnetInstallDir
Expand Down

0 comments on commit 167798e

Please sign in to comment.