windows-terminal/build
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
..
Fuzz Setup OneFuzz for CI (#10431) 2022-01-21 18:24:06 +00:00
Helix Plumb test failures through to github (#15831) 2023-08-15 09:50:15 -05:00
StoreSubmission Localize PDP changelogs - main - 08/16/2024 23:36:05 (#17732) 2024-08-19 13:52:54 -05:00
config build: add a OneBranch Official release pipeline (#16081) 2023-10-02 14:52:54 -05:00
pgo Rewrite the entire Azure DevOps build system (#15808) 2023-08-11 14:06:30 -05:00
pipelines Disable PGO for Release builds (#17765) 2024-08-21 16:21:05 -07:00
rules Use WinGet API to improve Quick Fix results (#17614) 2024-08-23 19:20:29 +02:00
scripts Fix more PDP ploc related issues (#17530) 2024-07-08 16:33:54 -07:00
packages.config chore: Update to TAEF 10.93.240607003 (#16595) 2024-08-16 22:50:19 +00:00