Skip to content

Commit

Permalink
Bug fix for installing from ADO feeds with v2 endpoints (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
alerickson authored Oct 4, 2023
1 parent 19abab7 commit 8e1bba8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
}

Expand Down Expand Up @@ -1145,8 +1147,14 @@ private Stream InstallVersion(string packageName, string version, out ErrorRecor
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallVersion()");
string requestUrlV2;

if (_isADORepo)
{
// eg: https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/nuget/v2?id=test_module&version=5.0.0
requestUrlV2 = $"{Repository.Uri}?id={packageName}&version={version}";
}
if (_isJFrogRepo)
{
// eg: https://<project>.jfrog.io/artifactory/api/nuget/<feed>/Download/test_module/5.0.0
requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{version}";
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/code/V3ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ public override FindResults FindVersionWithTag(string packageName, string versio
/// </summary>
public override Stream InstallPackage(string packageName, string packageVersion, bool includePrerelease, out ErrorRecord errRecord)
{
Stream results = new MemoryStream();
_cmdletPassedIn.WriteDebug("In V3ServerAPICalls::InstallPackage()");
Stream results = new MemoryStream();
if (string.IsNullOrEmpty(packageVersion))
{
results = InstallName(packageName, out errRecord);
Expand Down

0 comments on commit 8e1bba8

Please sign in to comment.