Skip to content

Commit

Permalink
Pinned WinGet packages are not loaded in Dev Home (#3596)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmelBawa-msft authored Aug 13, 2024
1 parent 3c86d44 commit 0d3446a
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public WinGetPackage(ILogger logger, CatalogPackage package, bool requiresElevat
// longer running).
_logger = logger;
Id = package.Id;
CatalogId = package.DefaultInstallVersion.PackageCatalog.Info.Id;
CatalogName = package.DefaultInstallVersion.PackageCatalog.Info.Name;
CatalogId = GetPackageVersionInfo(package).PackageCatalog.Info.Id;
CatalogName = GetPackageVersionInfo(package).PackageCatalog.Info.Name;
UniqueKey = new(Id, CatalogId);
Name = package.Name;
AvailableVersions = package.AvailableVersions.Select(v => v.Version).ToList();
Expand Down Expand Up @@ -81,6 +81,22 @@ public WinGetPackageUri GetUri(string installVersion = null)
return new(CatalogName, Id, uriOptions);
}

private PackageVersionInfo GetPackageVersionInfo(CatalogPackage package)
{
// Pinned packages do not have a default install version set
if (package.DefaultInstallVersion != null)
{
return package.DefaultInstallVersion;
}

if (package.AvailableVersions.Count > 0)
{
return package.GetPackageVersionInfo(package.AvailableVersions[0]);
}

throw new ArgumentException($"Package {package.Name} does not have any versions");
}

/// <summary>
/// Gets the package metadata from the current culture name (e.g. 'en-US')
/// </summary>
Expand All @@ -94,7 +110,7 @@ private T GetMetadataValue<T>(CatalogPackage package, Func<CatalogPackageMetadat
try
{
var locale = Thread.CurrentThread.CurrentCulture.Name;
var metadata = package.DefaultInstallVersion.GetCatalogPackageMetadata(locale);
var metadata = GetPackageVersionInfo(package).GetCatalogPackageMetadata(locale);
return metadataFunction(metadata);
}
catch
Expand Down

0 comments on commit 0d3446a

Please sign in to comment.