From 75bcffc7a24bf1828c86b1243962fedac0bf0a8f Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 25 Jul 2025 16:02:57 -0400 Subject: [PATCH 1/3] Handle tool/directory copy better --- eng/common/mcp/azure-sdk-mcp.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/eng/common/mcp/azure-sdk-mcp.ps1 b/eng/common/mcp/azure-sdk-mcp.ps1 index af6f342a3275..446b20b2dadf 100755 --- a/eng/common/mcp/azure-sdk-mcp.ps1 +++ b/eng/common/mcp/azure-sdk-mcp.ps1 @@ -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 } From d91cc1a1e44667c368f8c631c12496476028f2ff Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 25 Jul 2025 16:03:48 -0400 Subject: [PATCH 2/3] Use /usr/bin/env instead of /bin/env --- eng/common/mcp/azure-sdk-mcp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/mcp/azure-sdk-mcp.ps1 b/eng/common/mcp/azure-sdk-mcp.ps1 index 446b20b2dadf..331155516005 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 From f7793c6e545eb7b919d77f43f437ea66494fa974 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 25 Jul 2025 16:11:31 -0400 Subject: [PATCH 3/3] Append additional newline --- eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 b/eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1 index ed71854ecc40..8d74ece07dd9 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 +}