From 503f749dab491a07a2f3db5e069319d7156fcaf4 Mon Sep 17 00:00:00 2001 From: Sean Williams <72675818+sean-r-williams@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:42:23 -0700 Subject: [PATCH 1/2] Add prerelease string when NormalizedVersion doesn't exist (but prerelease string does) --- src/code/InstallHelper.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index cd86fe180..4bc670983 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -804,6 +804,9 @@ private Hashtable BeginPackageInstall( pkgToInstall.AdditionalMetadata.TryGetValue("NormalizedVersion", out string pkgVersion); if (pkgVersion == null) { pkgVersion = pkgToInstall.Version.ToString(); + if (!String.IsNullOrEmpty(pkgToInstall.Prerelease)) { + pkgVersion += $"-{pkgToInstall.Prerelease}"; + } } // Check to see if the pkg is already installed (ie the pkg is installed and the version satisfies the version range provided via param) if (!_reinstall) From e05bbef32a46417f5933eb438598e5b7aa6864e9 Mon Sep 17 00:00:00 2001 From: Sean Williams <72675818+sean-r-williams@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:44:10 -0700 Subject: [PATCH 2/2] Add explanatory comment --- src/code/InstallHelper.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/code/InstallHelper.cs b/src/code/InstallHelper.cs index 4bc670983..9057eda10 100644 --- a/src/code/InstallHelper.cs +++ b/src/code/InstallHelper.cs @@ -803,6 +803,8 @@ private Hashtable BeginPackageInstall( pkgToInstall.RepositorySourceLocation = repository.Uri.ToString(); pkgToInstall.AdditionalMetadata.TryGetValue("NormalizedVersion", out string pkgVersion); if (pkgVersion == null) { + // Not all NuGet providers (e.g. Artifactory, possibly others) send NormalizedVersion in NuGet package responses. + // If they don't, we need to manually construct the combined version+prerelease from pkgToInstall.Version and the prerelease string. pkgVersion = pkgToInstall.Version.ToString(); if (!String.IsNullOrEmpty(pkgToInstall.Prerelease)) { pkgVersion += $"-{pkgToInstall.Prerelease}";