From f948a9cbdaf39d4ae1244e01a86e3419e83808a5 Mon Sep 17 00:00:00 2001 From: Andreas Weizel Date: Thu, 20 Jun 2013 01:53:56 +0200 Subject: [PATCH] Fix for version comparison issue showing already installed packages as "update" in repository. --- .../AddInManager2/Project/Src/Model/AddInSetup.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs index 7554d400cc..a7b18f701d 100644 --- a/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs +++ b/src/AddIns/Misc/AddInManager2/Project/Src/Model/AddInSetup.cs @@ -808,7 +808,20 @@ namespace ICSharpCode.AddInManager2.Model } } - return addInVersion.CompareTo(nuGetPackage.Version.Version); + // Patch versions to have all 4 sub-numbers in both (workarounding bad NuGet Core behaviour with versions) + Version fixedAddInVersion = new Version( + (addInVersion.Major >= 0) ? addInVersion.Major : 0, + (addInVersion.Minor >= 0) ? addInVersion.Minor : 0, + (addInVersion.Build >= 0) ? addInVersion.Build : 0, + (addInVersion.Revision >= 0) ? addInVersion.Revision : 0); + Version nuGetVersion = nuGetPackage.Version.Version; + Version fixedNuGetVersion = new Version( + (nuGetVersion.Major >= 0) ? nuGetVersion.Major : 0, + (nuGetVersion.Minor >= 0) ? nuGetVersion.Minor : 0, + (nuGetVersion.Build >= 0) ? nuGetVersion.Build : 0, + (nuGetVersion.Revision >= 0) ? nuGetVersion.Revision : 0); + + return fixedAddInVersion.CompareTo(fixedNuGetVersion); } public void RemoveUnreferencedNuGetPackages()