terminal/build/rules
Carlos Zamora dbbc581154
Use WinGet API to improve Quick Fix results (#17614)
## Summary of the Pull Request
Improves Quick Fix's suggestions to use WinGet API and actually query
winget for packages based on the missing command.

To interact with the WinGet API, we need the
`Microsoft.WindowsPackageManager.ComInterop` NuGet package.
`Microsoft.WindowsPackageManager.ComInterop.Additional.targets` is used
to copy over the winmd into CascadiaPackage. The build variable
`TerminalWinGetInterop` is used to import the package properly.

`WindowsPackageManagerFactory` is used as a centralized way to generate
the winget objects. Long-term, we may need to do manual activation for
elevated sessions, which this class can easily be extended to support.
In the meantime, we'll just use the normal `winrt::create_instance` on
all sessions.

In `TerminalPage`, we conduct the search asynchronously when a missing
command was found. Search results are limited to 20 packages. We try to
retrieve packages with the following filters set, then fallback into the
next step:
1. `PackageMatchField::Command`,
`PackageFieldMatchOption::StartsWithCaseInsensitive`
2. `PackageMatchField::Name`,
`PackageFieldMatchOption::ContainsCaseInsensitive`
3. `PackageMatchField::Moniker`,
`PackageFieldMatchOption::ContainsCaseInsensitive`

This aligns with the Microsoft.WinGet.CommandNotFound PowerShell module
([link to relevant
code](9bc83617b9/src/WinGetCommandNotFoundFeedbackPredictor.cs (L165-L202))).

Closes #17378
Closes #17631
Support for elevated sessions tracked in #17677

## References
-
https://github.com/microsoft/winget-cli/blob/master/src/Microsoft.Management.Deployment/PackageManager.idl:
winget object documentation

## Validation Steps Performed
- [X] unelevated sessions --> winget query performed and presented
- [X] elevated sessions --> nothing happens (got rid of `winget install
{}` suggestion)
2024-08-23 19:20:29 +02:00
..
Branding.targets Add a Canary branding option (#15865) 2023-08-23 11:17:11 -05:00
CollectWildcardResources.targets Make ToolsVersion more consistent in our project files (#13535) 2022-07-26 22:31:42 +00:00
GenerateFeatureFlags.proj Fix the velocity script to actually support canary (#16810) 2024-03-04 14:03:27 -06:00
GenerateSxsManifestsFromWinmds.targets Project build with space in filepath fix (#15447) 2023-06-06 23:15:37 +00:00
Microsoft.UI.Xaml.Additional.targets Upgrade to MUX 2.8 (#15078) 2023-04-03 22:40:46 +00:00
Microsoft.WindowsPackageManager.ComInterop.Additional.targets Use WinGet API to improve Quick Fix results (#17614) 2024-08-23 19:20:29 +02:00