cmdpal: Skip dependency installs for extensions (#38175)

It appears there are two issues in WinGet regarding the installation of dependencies.

https://github.com/microsoft/winget-cli/issues/4661 https://github.com/microsoft/winget-cli/issues/4679

For CmdPal 0.1, we're going to skip installing dependencies to make extension installation more robust. This will mostly work because extensions will depend on the same frameworks as the command palette itself (for now).

We will revert this once these two issues are fixed.
This commit is contained in:
Mike Griese
2025-03-26 16:16:34 -05:00
committed by GitHub
parent 60bbf070e1
commit 5157ffc895
2 changed files with 30 additions and 16 deletions

View File

@@ -17,7 +17,6 @@ namespace Microsoft.CmdPal.Ext.WinGet.Pages;
public partial class InstallPackageCommand : InvokableCommand public partial class InstallPackageCommand : InvokableCommand
{ {
private readonly CatalogPackage _package; private readonly CatalogPackage _package;
private readonly StatusMessage _installBanner = new(); private readonly StatusMessage _installBanner = new();
private IAsyncOperationWithProgress<InstallResult, InstallProgress>? _installAction; private IAsyncOperationWithProgress<InstallResult, InstallProgress>? _installAction;
private IAsyncOperationWithProgress<UninstallResult, UninstallProgress>? _unInstallAction; private IAsyncOperationWithProgress<UninstallResult, UninstallProgress>? _unInstallAction;
@@ -43,6 +42,8 @@ public partial class InstallPackageCommand : InvokableCommand
private static readonly CompositeFormat UninstallPackageFinishing = System.Text.CompositeFormat.Parse(Properties.Resources.winget_uninstall_package_finishing); private static readonly CompositeFormat UninstallPackageFinishing = System.Text.CompositeFormat.Parse(Properties.Resources.winget_uninstall_package_finishing);
private static readonly CompositeFormat DownloadProgress = System.Text.CompositeFormat.Parse(Properties.Resources.winget_download_progress); private static readonly CompositeFormat DownloadProgress = System.Text.CompositeFormat.Parse(Properties.Resources.winget_download_progress);
internal bool SkipDependencies { get; set; }
public InstallPackageCommand(CatalogPackage package, bool isInstalled) public InstallPackageCommand(CatalogPackage package, bool isInstalled)
{ {
_package = package; _package = package;
@@ -96,6 +97,9 @@ public partial class InstallPackageCommand : InvokableCommand
var installOptions = WinGetStatics.WinGetFactory.CreateInstallOptions(); var installOptions = WinGetStatics.WinGetFactory.CreateInstallOptions();
installOptions.PackageInstallScope = PackageInstallScope.Any; installOptions.PackageInstallScope = PackageInstallScope.Any;
installOptions.SkipDependencies = SkipDependencies;
_installAction = WinGetStatics.Manager.InstallPackageAsync(_package, installOptions); _installAction = WinGetStatics.Manager.InstallPackageAsync(_package, installOptions);
var handler = new AsyncOperationProgressHandler<InstallResult, InstallProgress>(OnInstallProgress); var handler = new AsyncOperationProgressHandler<InstallResult, InstallProgress>(OnInstallProgress);

View File

@@ -31,7 +31,7 @@ public partial class InstallPackageListItem : ListItem
{ {
_package = package; _package = package;
PackageVersionInfo version = _package.DefaultInstallVersion; var version = _package.DefaultInstallVersion;
var versionTagText = "Unknown"; var versionTagText = "Unknown";
if (version != null) if (version != null)
{ {
@@ -49,16 +49,24 @@ public partial class InstallPackageListItem : ListItem
private Details? BuildDetails(PackageVersionInfo? version) private Details? BuildDetails(PackageVersionInfo? version)
{ {
CatalogPackageMetadata? metadata = version?.GetCatalogPackageMetadata(); var metadata = version?.GetCatalogPackageMetadata();
if (metadata != null) if (metadata != null)
{ {
if (metadata.Tags.Where(t => t.Equals(WinGetExtensionPage.ExtensionsTag, StringComparison.OrdinalIgnoreCase)).Any())
{
if (_installCommand != null)
{
_installCommand.SkipDependencies = true;
}
}
var description = string.IsNullOrEmpty(metadata.Description) ? metadata.ShortDescription : metadata.Description; var description = string.IsNullOrEmpty(metadata.Description) ? metadata.ShortDescription : metadata.Description;
var detailsBody = $""" var detailsBody = $"""
{description} {description}
"""; """;
IconInfo heroIcon = new(string.Empty); IconInfo heroIcon = new(string.Empty);
IReadOnlyList<Icon> icons = metadata.Icons; var icons = metadata.Icons;
if (icons.Count > 0) if (icons.Count > 0)
{ {
// There's also a .Theme property we could probably use to // There's also a .Theme property we could probably use to
@@ -89,21 +97,23 @@ public partial class InstallPackageListItem : ListItem
{ Properties.Resources.winget_publisher, (metadata.Publisher, metadata.PublisherUrl) }, { Properties.Resources.winget_publisher, (metadata.Publisher, metadata.PublisherUrl) },
{ Properties.Resources.winget_copyright, (metadata.Copyright, metadata.CopyrightUrl) }, { Properties.Resources.winget_copyright, (metadata.Copyright, metadata.CopyrightUrl) },
{ Properties.Resources.winget_license, (metadata.License, metadata.LicenseUrl) }, { Properties.Resources.winget_license, (metadata.License, metadata.LicenseUrl) },
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) }, { Properties.Resources.winget_publisher_support, (string.Empty, metadata.PublisherSupportUrl) },
// The link to the release notes will only show up if there is an // The link to the release notes will only show up if there is an
// actual URL for the release notes // actual URL for the release notes
{ Properties.Resources.winget_view_release_notes, (string.IsNullOrEmpty(metadata.ReleaseNotesUrl) ? string.Empty : Properties.Resources.winget_view_online, metadata.ReleaseNotesUrl) }, { Properties.Resources.winget_view_release_notes, (string.IsNullOrEmpty(metadata.ReleaseNotesUrl) ? string.Empty : Properties.Resources.winget_view_online, metadata.ReleaseNotesUrl) },
{ Properties.Resources.winget_publisher_support, (string.Empty, metadata.PublisherSupportUrl) },
// These can be l o n g
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) },
}; };
Documentation[] docs = metadata.Documentations.ToArray(); var docs = metadata.Documentations.ToArray();
foreach (Documentation? item in docs) foreach (var item in docs)
{ {
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl)); simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
} }
UriCreationOptions options = default; UriCreationOptions options = default;
foreach (KeyValuePair<string, (string, string)> kv in simpleData) foreach (var kv in simpleData)
{ {
var text = string.IsNullOrEmpty(kv.Value.Item1) ? kv.Value.Item2 : kv.Value.Item1; var text = string.IsNullOrEmpty(kv.Value.Item1) ? kv.Value.Item2 : kv.Value.Item1;
var target = kv.Value.Item2; var target = kv.Value.Item2;
@@ -136,8 +146,8 @@ public partial class InstallPackageListItem : ListItem
private async void UpdatedInstalledStatus() private async void UpdatedInstalledStatus()
{ {
CheckInstalledStatusResult status = await _package.CheckInstalledStatusAsync(); var status = await _package.CheckInstalledStatusAsync();
bool isInstalled = _package.InstalledVersion != null; var isInstalled = _package.InstalledVersion != null;
// might be an uninstall command // might be an uninstall command
InstallPackageCommand installCommand = new(_package, isInstalled); InstallPackageCommand installCommand = new(_package, isInstalled);
@@ -155,8 +165,8 @@ public partial class InstallPackageListItem : ListItem
if (WinGetStatics.AppSearchCallback != null) if (WinGetStatics.AppSearchCallback != null)
{ {
Func<string, ICommandItem?> callback = WinGetStatics.AppSearchCallback; var callback = WinGetStatics.AppSearchCallback;
ICommandItem? installedApp = callback(_package.DefaultInstallVersion == null ? _package.Name : _package.DefaultInstallVersion.DisplayName); var installedApp = callback(_package.DefaultInstallVersion == null ? _package.Name : _package.DefaultInstallVersion.DisplayName);
if (installedApp != null) if (installedApp != null)
{ {
this.Command = installedApp.Command; this.Command = installedApp.Command;
@@ -193,11 +203,11 @@ public partial class InstallPackageListItem : ListItem
Stopwatch s = new(); Stopwatch s = new();
Logger.LogDebug($"Starting RefreshPackageCatalogAsync"); Logger.LogDebug($"Starting RefreshPackageCatalogAsync");
s.Start(); s.Start();
PackageCatalogReference[] refs = WinGetStatics.AvailableCatalogs.ToArray(); var refs = WinGetStatics.AvailableCatalogs.ToArray();
foreach (PackageCatalogReference? catalog in refs) foreach (var catalog in refs)
{ {
global::Windows.Foundation.IAsyncOperationWithProgress<RefreshPackageCatalogResult, double> operation = catalog.RefreshPackageCatalogAsync(); var operation = catalog.RefreshPackageCatalogAsync();
operation.Wait(); operation.Wait();
} }