From db0c53da47702e8214d8f78e06a52358366b6910 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 16 Jun 2023 13:26:17 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 6300 (#2590) * add fallback onto azure.sdk.tools.testproxy within generate-assets-json.ps1 Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com> Co-authored-by: Sameeksha Vaity Co-authored-by: Konrad Jamrozik --- .../generate-assets-json.ps1 | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 index 3f43c7d3ad..7ecd8408af 100644 --- a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 +++ b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 @@ -138,11 +138,18 @@ class Version { } Function Test-Exe-In-Path { - Param([string] $ExeToLookFor) + Param([string] $ExeToLookFor, [bool]$ExitOnError = $true) if ($null -eq (Get-Command $ExeToLookFor -ErrorAction SilentlyContinue)) { - Write-Error "Unable to find $ExeToLookFor in your PATH" - exit 1 + if ($ExitOnError) { + Write-Error "Unable to find $ExeToLookFor in your PATH" + exit 1 + } + else { + return $false + } } + + return $true } Function Test-TestProxyVersion { @@ -348,9 +355,29 @@ $language = Get-Repo-Language # in the path and that we're able to map the language's recording # directories if ($InitialPush) { - Test-Exe-In-Path -ExeToLookFor $TestProxyExe + $proxyPresent = Test-Exe-In-Path -ExeToLookFor $TestProxyExe -ExitOnError $false + + # try to fall back + if (-not $proxyPresent) { + $StandaloneTestProxyExe = "Azure.Sdk.Tools.TestProxy" + + if ($IsWindows) { + $StandaloneTestProxyExe += ".exe" + } + + $standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneTestProxyExe -ExitOnError $false + + if ($standalonePresent) { + Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneTestProxyExe is. Updating proxy exe to use the standalone version." + $TestProxyExe = $StandaloneTestProxyExe + } + else { + Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor standalone executable $StandaloneTestProxyExe are installed on this machine." + exit 1 + } + } - if ($TestProxyExe -eq "test-proxy") { + if ($TestProxyExe -eq "test-proxy" -or $TestProxyExe.StartsWith("Azure.Sdk.Tools.TestProxy")) { Test-TestProxyVersion -TestProxyExe $TestProxyExe }