Skip to content

Commit a6706d7

Browse files
azure-sdkbenbp
andauthored
Sync eng/common directory with azure-sdk-tools for PR 11353 (#42230)
* Handle tool/directory copy better * Use /usr/bin/env instead of /bin/env * Append additional newline --------- Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
1 parent afb07fc commit a6706d7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env pwsh
1+
#!/usr/bin/env pwsh
22

33
#Requires -Version 7.0
44
#Requires -PSEdition Core
@@ -61,11 +61,14 @@ $tempExe = Install-Standalone-Tool `
6161
-Directory $tempInstallDirectory `
6262
-Repository $Repository
6363

64-
Copy-Item -Path $tempExe -Destination $toolInstallDirectory -Force
64+
if (-not (Test-Path $toolInstallDirectory)) {
65+
New-Item -ItemType Directory -Path $toolInstallDirectory -Force | Out-Null
66+
}
6567
$exeName = Split-Path $tempExe -Leaf
66-
$exe = Join-Path $toolInstallDirectory $exeName
68+
$exeDestination = Join-Path $toolInstallDirectory $exeName
69+
Copy-Item -Path $tempExe -Destination $exeDestination -Force
6770

68-
Write-Host "Package $package is installed at $exe"
71+
Write-Host "Package $package is installed at $exeDestination"
6972
if (!$UpdatePathInProfile) {
7073
Write-Warning "To add the tool to PATH for new shell sessions, re-run with -UpdatePathInProfile to modify the shell profile file."
7174
} else {
@@ -74,5 +77,5 @@ if (!$UpdatePathInProfile) {
7477
}
7578

7679
if ($Run) {
77-
Start-Process -WorkingDirectory $RunDirectory -FilePath $exe -ArgumentList 'start' -NoNewWindow -Wait
80+
Start-Process -WorkingDirectory $RunDirectory -FilePath $exeDestination -ArgumentList 'start' -NoNewWindow -Wait
7881
}

eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,6 @@ function Add-InstallDirectoryToPathInProfile(
247247

248248
if (!$configContent -or !$configContent.Contains($markerComment)) {
249249
Write-Host "Adding installation to PATH in shell profile at '$configFile'"
250-
Add-Content -Path $configFile -Value $pathCommand
250+
Add-Content -Path $configFile -Value ([Environment]::NewLine + $pathCommand)
251251
}
252-
}
252+
}

0 commit comments

Comments
 (0)