Skip to content

Commit

Permalink
(chocolatey#3433) Enable pre-release when resolving dependencies
Browse files Browse the repository at this point in the history
This updates the configuration when we are attempting to resolve the
dependencies of a packages when the package requested is explicitly
specified as a pre-release version.

This allows dependencies that are pre-releases to also be resolved
during this cases.
  • Loading branch information
AdmiringWorm authored and gep13 committed May 3, 2024
1 parent 99a2be0 commit 7a1dc80
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ Version was specified as '{0}'. It is possible that version
continue;
}

var oldPrerelease = config.Prerelease;
config.Prerelease = config.Prerelease || availablePackage.Identity.Version.IsPrerelease;
NugetCommon.GetPackageDependencies(availablePackage.Identity, NuGetFramework.AnyFramework, sourceCacheContext, _nugetLogger, remoteEndpoints, sourcePackageDependencyInfos, new HashSet<PackageDependency>(), config).GetAwaiter().GetResult();
config.Prerelease = oldPrerelease;

if (installedPackage != null && (installedPackage.PackageMetadata.Version == availablePackage.Identity.Version) && config.Force)
{
Expand Down Expand Up @@ -764,6 +767,7 @@ Version was specified as '{0}'. It is possible that version
this.Log().Error(ChocolateyLoggers.Important, logMessage);

foreach (var pkgMetadata in packagesToInstall)

{
var errorResult = packageResultsToReturn.GetOrAdd(pkgMetadata.Identity.Id, new PackageResult(pkgMetadata, pathResolver.GetInstallPath(pkgMetadata.Identity)));
errorResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
Expand Down Expand Up @@ -1281,7 +1285,10 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
{
localPackageListValid = false;

var oldPrerelease = config.Prerelease;
config.Prerelease = config.Prerelease || availablePackage.Identity.Version.IsPrerelease;
NugetCommon.GetPackageDependencies(availablePackage.Identity, NuGetFramework.AnyFramework, sourceCacheContext, _nugetLogger, remoteEndpoints, sourcePackageDependencyInfos, sourceDependencyCache, config).GetAwaiter().GetResult();
config.Prerelease = oldPrerelease;

packagesToUninstall.Add(installedPackage);

Expand Down Expand Up @@ -1323,7 +1330,10 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon

if (requestedPackageDependency != null)
{
oldPrerelease = config.Prerelease;
config.Prerelease = config.Prerelease || availablePackage.Identity.Version.IsPrerelease;
NugetCommon.GetPackageDependencies(requestedPackageDependency.Identity, NuGetFramework.AnyFramework, sourceCacheContext, _nugetLogger, remoteEndpoints, sourcePackageDependencyInfos, sourceDependencyCache, config).GetAwaiter().GetResult();
config.Prerelease = oldPrerelease;
}
}

Expand All @@ -1336,7 +1346,10 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon

if (availablePackageDependency != null)
{
oldPrerelease = config.Prerelease;
config.Prerelease = config.Prerelease || availablePackage.Identity.Version.IsPrerelease;
NugetCommon.GetPackageDependencies(availablePackageDependency.Identity, NuGetFramework.AnyFramework, sourceCacheContext, _nugetLogger, remoteEndpoints, sourcePackageDependencyInfos, sourceDependencyCache, config).GetAwaiter().GetResult();
config.Prerelease = oldPrerelease;
}
else
{
Expand Down Expand Up @@ -1456,7 +1469,10 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
{
foreach (var packageVersion in NugetList.FindAllPackageVersions(parentPackage.Id, config, _nugetLogger, sourceCacheContext, remoteEndpoints))
{
oldPrerelease = config.Prerelease;
config.Prerelease = config.Prerelease || availablePackage.Identity.Version.IsPrerelease;
NugetCommon.GetPackageDependencies(packageVersion.Identity, NuGetFramework.AnyFramework, sourceCacheContext, _nugetLogger, remoteEndpoints, sourcePackageDependencyInfos, sourceDependencyCache, config).GetAwaiter().GetResult();
config.Prerelease = oldPrerelease;
}
}

Expand Down

0 comments on commit 7a1dc80

Please sign in to comment.