Skip to content

Commit

Permalink
Merge branch 'artifactoryV2Bug' of https://github.com/alerickson/PSRe…
Browse files Browse the repository at this point in the history
…sourceGet into v2AdoBug
  • Loading branch information
alerickson committed Oct 4, 2023
2 parents f84558b + 78fe79f commit 54c36cd
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 296 deletions.
1 change: 1 addition & 0 deletions src/Microsoft.PowerShell.PSResourceGet.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function Import-PSGetRepository {
Trusted = $_.Trusted
PassThru = $true
Force = $Force
ApiVersion = 'v2'
}
Register-PSResourceRepository @registerPSResourceRepositorySplat
}
Expand Down
11 changes: 1 addition & 10 deletions src/code/IServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,7 @@ public interface IServerAPICalls
/// Name: no wildcard support.
/// Examples: Install "PowerShellGet"
/// </summary>
Stream InstallName(string packageName, string packageVersion, bool includePrerelease, out ErrorRecord errRecord);

/// <summary>
/// Installs package with specific name and version.
/// Name: no wildcard support.
/// Version: no wildcard support.
/// Examples: Install "PowerShellGet" -Version "3.0.0.0"
/// Install "PowerShellGet" -Version "3.0.0-beta16"
/// </summary>
Stream InstallVersion(string packageName, string version, out ErrorRecord errRecord);
Stream InstallPackage(string packageName, string packageVersion, bool includePrerelease, out ErrorRecord errRecord);

#endregion
}
28 changes: 7 additions & 21 deletions src/code/InstallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ private List<PSResourceInfo> InstallPackages(
// and value as a Hashtable of specific package info:
// packageName, { version = "", isScript = "", isModule = "", pkg = "", etc. }
// Install parent package to the temp directory.
Hashtable packagesHash = InstallPackage(
Hashtable packagesHash = BeginPackageInstall(
searchVersionType: _versionType,
specificVersion: _nugetVersion,
versionRange: _versionRange,
Expand Down Expand Up @@ -617,7 +617,7 @@ private List<PSResourceInfo> InstallPackages(
}
}

packagesHash = InstallPackage(
packagesHash = BeginPackageInstall(
searchVersionType: VersionType.SpecificVersion,
specificVersion: depVersion,
versionRange: null,
Expand Down Expand Up @@ -683,7 +683,7 @@ private List<PSResourceInfo> InstallPackages(
/// <summary>
/// Installs a single package to the temporary path.
/// </summary>
private Hashtable InstallPackage(
private Hashtable BeginPackageInstall(
VersionType searchVersionType,
NuGetVersion specificVersion,
VersionRange versionRange,
Expand Down Expand Up @@ -839,25 +839,11 @@ private Hashtable InstallPackage(
{
// Download the package.
string pkgName = pkgToInstall.Name;
Stream responseStream;

if (searchVersionType == VersionType.NoVersion && !_prerelease)
Stream responseStream = currentServer.InstallPackage(pkgName, pkgVersion, _prerelease, out ErrorRecord installNameErrRecord);
if (installNameErrRecord != null)
{
responseStream = currentServer.InstallName(pkgName, pkgVersion, _prerelease, out ErrorRecord installNameErrRecord);
if (installNameErrRecord != null)
{
errRecord = installNameErrRecord;
return packagesHash;
}
}
else
{
responseStream = currentServer.InstallVersion(pkgName, pkgVersion, out ErrorRecord installVersionErrRecord);
if (installVersionErrRecord != null)
{
errRecord = installVersionErrRecord;
return packagesHash;
}
errRecord = installNameErrRecord;
return packagesHash;
}

bool installedToTempPathSuccessfully = _asNupkg ? TrySaveNupkgToTempPath(responseStream, tempInstallPath, pkgName, pkgVersion, pkgToInstall, packagesHash, out updatedPackagesHash, out errRecord) :
Expand Down
Loading

0 comments on commit 54c36cd

Please sign in to comment.