diff --git a/src/code/V2ServerAPICalls.cs b/src/code/V2ServerAPICalls.cs index 5017d13da..d09195881 100644 --- a/src/code/V2ServerAPICalls.cs +++ b/src/code/V2ServerAPICalls.cs @@ -39,6 +39,7 @@ internal class V2ServerAPICalls : ServerApiCall private HttpClient _sessionClient { get; set; } private static readonly Hashtable[] emptyHashResponses = new Hashtable[]{}; public FindResponseType v2FindResponseType = FindResponseType.ResponseString; + private bool _isADORepo; private bool _isJFrogRepo; #endregion @@ -57,6 +58,7 @@ public V2ServerAPICalls (PSRepositoryInfo repository, PSCmdlet cmdletPassedIn, N _sessionClient = new HttpClient(handler); _sessionClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", userAgentString); var repoURL = repository.Uri.ToString().ToLower(); + _isADORepo = repoURL.Contains("pkgs.dev.azure.com") || repoURL.Contains("pkgs.visualstudio.com"); _isJFrogRepo = repoURL.Contains("jfrog"); } @@ -674,7 +676,12 @@ public override Stream InstallName(string packageName, string packageVersion, bo _cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallName()"); var requestUrlV2 = string.Empty; - if (_isJFrogRepo) + if (_isADORepo) + { + // eg: https://pkgs.dev.azure.com///_packaging//nuget/v2?id=test_local_mod&version=5.0.0 + requestUrlV2 = $"{Repository.Uri}?id={packageName}&version={packageVersion}"; + } + else if (_isJFrogRepo) { requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{packageVersion}"; } @@ -706,7 +713,12 @@ public override Stream InstallVersion(string packageName, string version, out Er _cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallVersion()"); var requestUrlV2 = string.Empty; - if (_isJFrogRepo) + if (_isADORepo) + { + // eg: https://pkgs.dev.azure.com///_packaging//nuget/v2?id=test_local_mod&version=5.0.0 + requestUrlV2 = $"{Repository.Uri}?id={packageName}&version={version}"; + } + else if (_isJFrogRepo) { requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{version}"; }