Skip to content

Commit

Permalink
Merge pull request #734 from CyberAndrii/fix/nuget-installs-the-lates…
Browse files Browse the repository at this point in the history
…t-version-instead-of-the-specified-one

Fix package manager installs the latest version of a package instead of the specified one
  • Loading branch information
Trojaner committed Aug 2, 2023
2 parents 75f1644 + 941e6d7 commit 7527c86
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using NuGet.Packaging.Core;
using NuGet.Versioning;
using OpenMod.API;
using OpenMod.API.Plugins;
using OpenMod.NuGet;
Expand Down Expand Up @@ -83,7 +85,11 @@ private async Task<NuGetInstallResult> InstallOrUpdateAsync(string packageName,
return new NuGetInstallResult(NuGetInstallCode.PackageOrVersionNotFound);
}

var result = await m_NuGetPackageManager.InstallAsync(package.Identity, isPreRelease);
var packageIdentity = version is null
? package.Identity
: new PackageIdentity(package.Identity.Id, new NuGetVersion(version));

var result = await m_NuGetPackageManager.InstallAsync(packageIdentity, isPreRelease);
if (result.Code is not NuGetInstallCode.Success and not NuGetInstallCode.NoUpdatesFound)
{
return result;
Expand Down

0 comments on commit 7527c86

Please sign in to comment.