From 6b2f6d075fbabbf143c204be3cad297b1a597635 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:21:14 -0700 Subject: [PATCH 1/4] add fallback for the test-proxy exe --- .../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 3f43c7d3adff..73022f2609c0 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) { + $StandaloneProxyExe = "Azure.Sdk.Tools.TestProxy" + + if ($IsWindows) { + $StandaloneProxyExe += ".exe" + } + + $standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneProxyExe -ExitOnError $false + + if ($standalonePresent) { + Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneProxyExe is. Updating proxy exe to standalone version." + $TestProxyExe = $StandaloneProxyExe + } + else { + Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor StandaloneProxyExe 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 } From f3599cfc7dcaa0524d18bd6eca3236961c35dd77 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Thu, 8 Jun 2023 11:29:10 -0700 Subject: [PATCH 2/4] Update eng/common/testproxy/transition-scripts/generate-assets-json.ps1 Co-authored-by: Sameeksha Vaity --- .../testproxy/transition-scripts/generate-assets-json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 index 73022f2609c0..8ef72325a5dd 100644 --- a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 +++ b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 @@ -368,7 +368,7 @@ if ($InitialPush) { $standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneProxyExe -ExitOnError $false if ($standalonePresent) { - Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneProxyExe is. Updating proxy exe to standalone version." + Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneProxyExe is. Updating proxy exe to use the standalone version." $TestProxyExe = $StandaloneProxyExe } else { From 347949edcda80c3e5a48b2a283c4a0735094ddf8 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Thu, 8 Jun 2023 13:18:21 -0700 Subject: [PATCH 3/4] Update eng/common/testproxy/transition-scripts/generate-assets-json.ps1 Co-authored-by: Konrad Jamrozik --- .../testproxy/transition-scripts/generate-assets-json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 index 8ef72325a5dd..5e2dd17f7eaa 100644 --- a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 +++ b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 @@ -372,7 +372,7 @@ if ($InitialPush) { $TestProxyExe = $StandaloneProxyExe } else { - Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor StandaloneProxyExe are installed on this machine." + Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor $StandaloneProxyExe are installed on this machine." exit 1 } } From 9d97951abcdabfeb150883a50f3a4eca7023c38d Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Thu, 8 Jun 2023 13:19:56 -0700 Subject: [PATCH 4/4] merge feedback --- .../transition-scripts/generate-assets-json.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 index 5e2dd17f7eaa..7ecd8408af01 100644 --- a/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 +++ b/eng/common/testproxy/transition-scripts/generate-assets-json.ps1 @@ -359,20 +359,20 @@ if ($InitialPush) { # try to fall back if (-not $proxyPresent) { - $StandaloneProxyExe = "Azure.Sdk.Tools.TestProxy" + $StandaloneTestProxyExe = "Azure.Sdk.Tools.TestProxy" if ($IsWindows) { - $StandaloneProxyExe += ".exe" + $StandaloneTestProxyExe += ".exe" } - $standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneProxyExe -ExitOnError $false + $standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneTestProxyExe -ExitOnError $false if ($standalonePresent) { - Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneProxyExe is. Updating proxy exe to use the standalone version." - $TestProxyExe = $StandaloneProxyExe + 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 $StandaloneProxyExe are installed on this machine." + 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 } }