Skip to content

Commit a0abd70

Browse files
azure-sdkbenbp
andauthored
Recover from local version parsing failures in install (#46234)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
1 parent b0631e2 commit a0abd70

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

eng/common/mcp/azure-sdk-mcp.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,28 @@ $guid = [System.Guid]::NewGuid()
105105
$tempInstallDirectory = Join-Path $tmp "azsdk-install-$($guid)"
106106

107107
# If already installed, use first class version mechanism
108-
$azsdkCmd = Get-Command -ErrorAction SilentlyContinue $packageName
108+
$azsdkCmd = Get-Command -ErrorAction Ignore $packageName
109109
if ($azsdkCmd -and !$InstallDirectory) {
110110
$ErrorActionPreference = "Stop"
111111
$upgrade = & $packageName upgrade --check --output json | out-string
112112
if (!$LASTEXITCODE) {
113113
$ErrorActionPreference = 'Ignore'
114114
$localVersion = $upgrade | ConvertFrom-Json -AsHashtable
115115
$ErrorActionPreference = 'Stop'
116-
if ($localVersion.old_version -and $localVersion.old_version -eq ($Version ? $Version : $localVersion.new_version)) {
116+
if ($localVersion -and $localVersion.old_version -and $localVersion.old_version -eq ($Version ? $Version : $localVersion.new_version)) {
117117
log "Version up to date at $($localVersion.old_version)"
118118
if ($Run) {
119119
$proc = Start-Process -PassThru -WorkingDirectory $RunDirectory -FilePath $azsdkCmd.Path -ArgumentList 'mcp' -NoNewWindow -Wait
120120
exit $proc.ExitCode
121121
}
122122
exit 0
123123
}
124-
log "Version not up to date at " + $localVersion.old_version
124+
if ($localVersion) {
125+
log "Version not up to date at " + $localVersion.old_version
126+
} else {
127+
log "Failed to parse version:"
128+
log $upgrade
129+
}
125130
}
126131
}
127132

0 commit comments

Comments
 (0)