From 9bfc124a8728b02d99b9f24be6080235e1abf5fe Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 25 Jul 2025 14:12:48 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 11353 (#6671) * Handle tool/directory copy better * Use /usr/bin/env instead of /bin/env * Append additional newline --------- Co-authored-by: Ben Broderick Phillips --- eng/common/mcp/azure-sdk-mcp.ps1 | 13 ++++++++----- eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/eng/common/mcp/azure-sdk-mcp.ps1 b/eng/common/mcp/azure-sdk-mcp.ps1 index af6f342a3..331155516 100755 --- a/eng/common/mcp/azure-sdk-mcp.ps1 +++ b/eng/common/mcp/azure-sdk-mcp.ps1 @@ -1,4 +1,4 @@ -#!/bin/env pwsh +#!/usr/bin/env pwsh #Requires -Version 7.0 #Requires -PSEdition Core @@ -61,11 +61,14 @@ $tempExe = Install-Standalone-Tool ` -Directory $tempInstallDirectory ` -Repository $Repository -Copy-Item -Path $tempExe -Destination $toolInstallDirectory -Force +if (-not (Test-Path $toolInstallDirectory)) { + New-Item -ItemType Directory -Path $toolInstallDirectory -Force | Out-Null +} $exeName = Split-Path $tempExe -Leaf -$exe = Join-Path $toolInstallDirectory $exeName +$exeDestination = Join-Path $toolInstallDirectory $exeName +Copy-Item -Path $tempExe -Destination $exeDestination -Force -Write-Host "Package $package is installed at $exe" +Write-Host "Package $package is installed at $exeDestination" if (!$UpdatePathInProfile) { Write-Warning "To add the tool to PATH for new shell sessions, re-run with -UpdatePathInProfile to modify the shell profile file." } else { @@ -74,5 +77,5 @@ if (!$UpdatePathInProfile) { } if ($Run) { - Start-Process -WorkingDirectory $RunDirectory -FilePath $exe -ArgumentList 'start' -NoNewWindow -Wait + Start-Process -WorkingDirectory $RunDirectory -FilePath $exeDestination -ArgumentList 'start' -NoNewWindow -Wait } diff --git a/eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 b/eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 index ed71854ec..8d74ece07 100644 --- a/eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 +++ b/eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 @@ -247,6 +247,6 @@ function Add-InstallDirectoryToPathInProfile( if (!$configContent -or !$configContent.Contains($markerComment)) { Write-Host "Adding installation to PATH in shell profile at '$configFile'" - Add-Content -Path $configFile -Value $pathCommand + Add-Content -Path $configFile -Value ([Environment]::NewLine + $pathCommand) } -} \ No newline at end of file +}