diff --git a/src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/Common/PackageCmdlet.cs b/src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/Common/PackageCmdlet.cs
index f001180d7c..0862e0d467 100644
--- a/src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/Common/PackageCmdlet.cs
+++ b/src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/Common/PackageCmdlet.cs
@@ -15,7 +15,16 @@ namespace Microsoft.WinGet.Client.Commands.Common
/// the "install", "uninstall", and "upgrade" commands.
///
public abstract class PackageCmdlet : FinderCmdlet
- {
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public PackageCmdlet()
+ {
+ // The default match option for single package operations.
+ this.MatchOption = PSObjects.PSPackageFieldMatchOption.EqualsCaseInsensitive;
+ }
+
///
/// Gets or sets the package to directly install.
///
diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/FinderCommand.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/FinderCommand.cs
index 9abd4be441..a739d1526e 100644
--- a/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/FinderCommand.cs
+++ b/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/FinderCommand.cs
@@ -88,7 +88,13 @@ protected IReadOnlyList FindPackages(
return GetMatchResults(catalog, options);
}
- private static void SetQueryInFindPackagesOptions(
+ ///
+ /// Sets the find package options for a query input.
+ ///
+ /// The options object.
+ /// The match type.
+ /// The query value.
+ protected virtual void SetQueryInFindPackagesOptions(
ref FindPackagesOptions options,
PackageFieldMatchOption match,
string value)
@@ -161,7 +167,7 @@ private PackageCatalogReference GetPackageCatalogReference(CompositeSearchBehavi
private FindPackagesOptions GetFindPackagesOptions(uint limit)
{
var options = ComObjectFactory.Value.CreateFindPackagesOptions();
- SetQueryInFindPackagesOptions(ref options, this.MatchOption, this.QueryAsJoinedString);
+ this.SetQueryInFindPackagesOptions(ref options, this.MatchOption, this.QueryAsJoinedString);
this.AddAttributedFiltersToFindPackagesOptions(ref options, this.MatchOption);
options.ResultLimit = limit;
return options;
diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/PackageCommand.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/PackageCommand.cs
index 7361e4f20d..e6b384ac83 100644
--- a/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/PackageCommand.cs
+++ b/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/Common/PackageCommand.cs
@@ -63,6 +63,27 @@ protected void GetPackageAndExecute(
}
}
+ ///
+ /// Sets the find package options for a query input that is looking for a specific package.
+ ///
+ /// The options object.
+ /// The match type.
+ /// The query value.
+ protected override void SetQueryInFindPackagesOptions(
+ ref FindPackagesOptions options,
+ PackageFieldMatchOption match,
+ string value)
+ {
+ foreach (PackageMatchField field in new PackageMatchField[] { PackageMatchField.Id, PackageMatchField.Name, PackageMatchField.Moniker })
+ {
+ var selector = ComObjectFactory.Value.CreatePackageMatchFilter();
+ selector.Field = field;
+ selector.Value = value ?? string.Empty;
+ selector.Option = match;
+ options.Selectors.Add(selector);
+ }
+ }
+
private CatalogPackage GetCatalogPackage(CompositeSearchBehavior behavior)
{
if (this.CatalogPackage != null)