Skip to content

Commit

Permalink
Update DetectVersionService.cs (#1684)
Browse files Browse the repository at this point in the history
* Update DetectVersionService.cs

The package search will search the winget repository and will always return the newest version. Package.Version and Package.AvailableVersion will always be the same here.
I changed it to `GetInstalledPackages(packageId)` instead of `SearchPackage(PackageId)`. This will give you the correct installed and available version and should also be faster, because you are just going through the installed packages.

* Update DetectVersionService.cs

---------

Co-authored-by: Martin Hinshelwood nkdAgility.com <martin@nkdagility.com>
  • Loading branch information
basicx-StrgV and MrHinsh authored Oct 18, 2023
1 parent f0fe2f8 commit e086c96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MigrationTools.Host/Services/DetectVersionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Version GetLatestVersion()
try
{
WinGetPackageManager packageManager = new WinGetPackageManager();
var package = packageManager.SearchPackage(PackageId).SingleOrDefault();
var package = packageManager.GetInstalledPackages(PackageId).GroupBy(e => e.Id, (id, g) => g.First()).SingleOrDefault();

latestPackageVersion = new Version(package.AvailableVersion);
if (latestPackageVersion != null)
Expand All @@ -57,4 +57,4 @@ public Version GetLatestVersion()
return latestPackageVersion;
}
}
}
}

0 comments on commit e086c96

Please sign in to comment.