Repository: tauri
Issue: [feat] Windows - Build MSIX Packages to Support Package Extensions
Labels: type: feature request

### Describe the problem

There are a number of windows features that require a desktop app to have [package identity](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/modernize-packaged-apps). For example, you can use a [package extension](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions) to have websites redirect to your desktop application ([app URI handlers](https://docs.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-linking)) similar to universal links on iOS.

The issue is that Tauri apps build to msi which cannot have package identity, so we can't use the features above in our apps. We'd need to build to MSIX to do this.

### Describe the solution you'd like

## Enabling Package Extensions from Config
If we implemented package identity under the hood (as in, build msix packages), then it'd be great to give config options for some useful [package extensions](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions), such as [`windows.appUriHandler`](https://docs.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-linking). This would for instance increase OAuth 2.0 support in Tauri, since we'd have a method other than [custom URI schemes](https://github.com/tauri-apps/tauri/issues/323) or localhost servers to accept OAuth 2.0 requests from the system default browser. [Discord thread](https://discordapp.com/channels/616186924390023171/990632073322721341/990723231440855121) for reference.

## Option for Package Identity: Sparse Package
Microsoft outlines 2 ways to obtain package identity:

- Build MSIX directly from your [source code](https://docs.microsoft.com/en-us/windows/msix/desktop/source-code-overview) (discussed as an alternative below)
- Build a [sparse package](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps), which notably is ⚠ only supported in Windows 10 version 2004 and later

A sparse package effectively sits beside your existing apps and adds additional features using an MSIX that points at your existing MSI based app. It seems like a much lower lift than building MSIX from source, for some reasons discussed in the alternatives section below.

Microsoft has a nice [tutorial](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps) outlining how to generate a sparse package, and here's where I expect the complexity to be for Tauri:
- The [additional build step](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps#build-and-sign-the-sparse-package) includes signing the package. We'd need a system for choosing/generating a certificate to sign the package with
- There is a [run-time registration step](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps#register-your-sparse-package-at-run-time) we'd need to introduce. I'm not actually sure if this goes in the MSI or MSIX 🤷‍♂️. That tutorial includes a code snippet, and WiX has some [documentation](https://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html) on injecting the action with a template. We'd just need to write a dll for this and include it in the %AppData%\Local\tauri\WixTools folder (I think)

### Alternatives considered

Creating [full MSIX packages](https://docs.microsoft.com/en-us/windows/msix/desktop/source-code-overview) instead of or in addition to MSI. This is nice because it's supported before ✔Windows 10 version 2004, but has a couple big drawbacks ❌:

- Wix doesn't currently support [MSIX](https://github.com/wixtoolset/issues/issues/5781), so we'd have to re-tool to one of the techniques in the link above
- There are a ton of [prereqs](https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-prepare) Tauri would need to meet in terms of what windows features it uses (example: Using a [background task](https://docs.microsoft.com/en-us/windows/uwp/launch-resume/create-and-register-a-background-task) instead of a windows service)
- [ ] I would appreciate if someone could review the prereqs list

### Additional context

I researched this because it's important for flexibility in using Tauri as an OAuth 2.0 client app. In [issue 323](https://github.com/tauri-apps/tauri/issues/323) I saw some confusion on this and wanted to call out based on [RFC 8252 section 8.12](https://datatracker.ietf.org/doc/html/rfc8252#section-8.12) you shouldn't be conducting OAuth 2.0 from a web-view. Instead, you should be launching to the system default browser and having it redirect back to the initial native app. Adding app URI Handler support would be a great way for Tauri apps to conduct this redirect.