\r
public void CheckUpgrade()\r
{\r
- PackageList<Package> packageList = pkgListMan.AvailablePkgList;\r
- string[] exclude = NaGet.Env.ExcludeUpdatePackageNames;\r
- \r
- VersionComparetor verComp = new VersionComparetor();\r
- \r
- foreach (InstalledPackage pkg in pkgListMan.InstalledPkgList) {\r
- if (Array.IndexOf(exclude ?? new string[0], pkg.Name) < 0) {\r
- Package avaiablePkg = packageList.GetPackageForName(pkg.Name);\r
- if (avaiablePkg != null) {\r
- if (verComp.Compare(pkg.Version, avaiablePkg.Version) < 0 &&\r
- pkgListMan.InstalledPkgList.GetPackageForPackage(pkg.Name, avaiablePkg.Version) == null) {\r
- \r
- Console.WriteLine("{0} ({1}) => ({2})", pkg.Name, pkg.Version, avaiablePkg.Version);\r
- }\r
- }\r
- }\r
- }\r
- foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList) {\r
- if (Array.IndexOf(exclude ?? new string[0], pkg.Name) < 0) {\r
- Package avaiablePkg = packageList.GetPackageForName(pkg.Name);\r
- \r
- if (avaiablePkg != null) {\r
- if (verComp.Compare(pkg.Version, avaiablePkg.Version) < 0 &&\r
- pkgListMan.SystemInstalledPkgList.GetPackageForPackage(pkg.Name, avaiablePkg.Version) == null) {\r
- \r
- Console.WriteLine("{0} ({1})@sys => ({2})", pkg.Name, pkg.Version, avaiablePkg.Version);\r
- }\r
+ foreach (Package pkg in UpgradeFinder.GetUpgradePackages(pkgListMan)) {\r
+ bool isSystem = false;\r
+ Package instPkg = null;\r
+ \r
+ instPkg = pkgListMan.SystemInstalledPkgList.GetPackageForName(pkg.Name);\r
+ if (instPkg != null) {\r
+ isSystem = true;\r
+ } else {\r
+ instPkg = pkgListMan.InstalledPkgList.GetPackageForName(pkg.Name);\r
+ if (instPkg != null) {\r
+ isSystem = false;\r
+ } else {\r
+ System.Diagnostics.Debug.Fail("internal error.");\r
}\r
}\r
+ \r
+ Console.WriteLine("{0} ({1}){3} => ({2})", pkg.Name, instPkg.Version, pkg.Version, (isSystem)? "@sys" : "");\r
}\r
}\r
\r
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using NaGet.Packages;
+
+namespace NaGet.Packages.Install
+{
+ /// <summary>
+ /// \8dX\90V\83\\83t\83g\82ð\92T\82·
+ /// </summary>
+ public sealed class UpgradeFinder
+ {
+ private UpgradeFinder()
+ {
+ }
+
+ private static Package getUpgradePkg(Package pkg, PackageList<Package> pkgList, PackageList<InstalledPackage> instPkgList, string[] exclude, IComparer<string> verComp)
+ {
+ Package avaiablePkg = pkgList.GetPackageForName(pkg.Name);
+ bool canUpgrade = false;
+
+ if (avaiablePkg != null) {
+
+ if (verComp.Compare(pkg.Version, avaiablePkg.Version) < 0 &&
+ instPkgList.GetPackageForPackage(pkg.Name, avaiablePkg.Version) == null) {
+ canUpgrade = true;
+
+ if (Array.IndexOf(exclude, pkg.Name) >= 0) {
+ canUpgrade = false;
+ }
+ }
+ }
+
+ return (canUpgrade)? avaiablePkg : null;
+ }
+
+ public static IEnumerable<Package> GetUpgradePackages(PackageListsManager pkgListMan)
+ {
+ PackageList<Package> packageList = pkgListMan.AvailablePkgList;
+ string[] exclude = NaGet.Env.ExcludeUpdatePackageNames ?? new string[0];
+
+ VersionComparetor verComp = new VersionComparetor();
+
+ foreach (InstalledPackage pkg in pkgListMan.InstalledPkgList) {
+ Package availablePkg = getUpgradePkg(pkg, packageList, pkgListMan.InstalledPkgList, exclude, verComp);
+ if (availablePkg != null) { // if it has an upgrade, yield
+ yield return availablePkg;
+ }
+ }
+ foreach (InstalledPackage pkg in pkgListMan.SystemInstalledPkgList) {
+ Package availablePkg = getUpgradePkg(pkg, packageList, pkgListMan.SystemInstalledPkgList, exclude, verComp);
+ if (availablePkg != null) { // if it has an upgrade, yield
+ yield return availablePkg;
+ }
+ }
+ }
+ }
+}
<Compile Include="NaGet.Net\GuidEnumeratorForCategories.cs" />\r
<Compile Include="NaGet.Packages.Install\DependeciesResolver.cs" />\r
<Compile Include="NaGet.Packages.Install\InstallationLog.cs" />\r
+ <Compile Include="NaGet.Packages.Install\UpgradeFinder.cs" />\r
<Compile Include="NaGet.Packages\PackageCollectionFileData.cs" />\r
<Compile Include="NaGet.Packages\PackageListsManager.cs" />\r
<Compile Include="NaGet.Packages\RepositoriesList.cs" />\r