Skip to content

Commit 855a53b

Browse files
azure-sdkraych1Copilot
authored
Sync eng/common directory with azure-sdk-tools for PR 13561 (#6910)
* Enabled multiple runs on windows * Update eng/common/mcp/azure-sdk-mcp.ps1 Co-authored-by: Copilot <[email protected]> * Updated the comment to be clearer * Falled back to installed version for MCP mode only * Made the error hanlding for all exceptions * Failed the run when error happens in first installation case. --------- Co-authored-by: Ray Chen <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent b101f18 commit 855a53b

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,34 @@ if (-not (Test-Path $toolInstallDirectory)) {
138138
}
139139
$exeName = Split-Path $tempExe -Leaf
140140
$exeDestination = Join-Path $toolInstallDirectory $exeName
141-
Copy-Item -Path $tempExe -Destination $exeDestination -Force
142141

143-
log "Package $package is installed at $exeDestination"
142+
# Try to copy the new version
143+
$updateSucceeded = $false
144+
try {
145+
Copy-Item -Path $tempExe -Destination $exeDestination -Force
146+
$updateSucceeded = $true
147+
}
148+
catch {
149+
if ($Run -and (Test-Path $exeDestination)) {
150+
# In MCP mode and the executable exists, warn and fall back to the existing installed version
151+
log -warn "Could not update '$exeDestination': $($_.Exception.Message)"
152+
log -warn "Falling back to the currently installed version."
153+
}
154+
else {
155+
# In update-only mode or the executable does not exist, exit with error
156+
log -err "Could not install or update '$exeDestination': $($_.Exception.Message)"
157+
exit 1
158+
}
159+
}
160+
161+
# Clean up temp directory
162+
if (Test-Path $tempInstallDirectory) {
163+
Remove-Item -Path $tempInstallDirectory -Recurse -Force -ErrorAction SilentlyContinue
164+
}
165+
166+
if ($updateSucceeded) {
167+
log "Executable $package is installed at $exeDestination"
168+
}
144169
if (!$UpdatePathInProfile) {
145170
log -warn "To add the tool to PATH for new shell sessions, re-run with -UpdatePathInProfile to modify the shell profile file."
146171
}

0 commit comments

Comments
 (0)