diff --git a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 index 3f43c7d3adff..7ecd8408af01 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 }