Repository: microsoft/terminal (language: cpp)

Issue:
Terminal XAML files should be in binary (.xbf) format for improved performance
### Windows Terminal version (or Windows build number)

Version: 1.11.2921.0

### Other Software

See [https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/optimize-xaml-loading#use-xbf2](https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/optimize-xaml-loading#use-xbf2) for some documentation on this topic.  Basically .xbf files are a binary-encoded version of the same content so they are smaller on disk, take up less memory when loaded, and are more efficiently processed by XAML.  To the best of my knowledge the conversion improves performance with little to no downside.

### Steps to reproduce

1) Open Terminal package root folder on my local device in explorer
2) Navigate to \TerminalApp directory
3) Observe a variety of loose .xaml files.  

### Expected Behavior

These files should be .xbf format for improved performance.

### Actual Behavior

The files are raw .xaml documents containing comments, spaces, formatting, etc. none of which is necessary for runtime correctness.


Discussion / hints:
`TerminalApp`:

![image](https://user-images.githubusercontent.com/18356694/140414941-28dd6704-d372-441e-adee-89c584fcc7d0.png)

`Terminal.Settings.Editor`:
![image](https://user-images.githubusercontent.com/18356694/140415034-39529a98-8fcf-4b59-95cc-5e51abf64ac4.png)


what the f

Why doesn't `TerminalApp` do this? It definitely _should_ be...

Note that even though Microsoft.Terminal.Settings.Editor seems to produce those they aren't shipping:

```
 Directory of C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.11.2921.0_x64__8wekyb3d8bbwe\Microsoft.Terminal.Settings.Editor

10/20/2021  04:25 PM    <DIR>          .
10/20/2021  04:25 PM    <DIR>          ..
10/20/2021  04:25 PM            25,833 Actions.xaml
10/20/2021  04:25 PM             4,980 AddProfile.xaml
10/20/2021  04:25 PM            28,816 Appearances.xaml
10/20/2021  04:25 PM            21,394 ColorSchemes.xaml
09/03/2021  03:26 PM             6,482 CommonResources.xaml
10/20/2021  04:25 PM             5,884 GlobalAppearance.xaml
10/20/2021  04:25 PM             4,132 Interaction.xaml
10/20/2021  04:25 PM               838 KeyChordListener.xaml
10/20/2021  04:25 PM            10,081 Launch.xaml
09/03/2021  03:26 PM             8,044 MainPage.xaml
10/20/2021  04:25 PM            36,631 Profiles.xaml
10/20/2021  04:25 PM            11,628 ReadOnlyActions.xaml
09/03/2021  03:26 PM             1,770 Rendering.xaml
08/26/2021  06:12 AM             2,780 SettingContainerStyle.xaml
```
So, `TerminalApp` actually _is_ using `xbf`; the files are just not present on disk.

https://github.com/microsoft/terminal/blob/761203d95e94987aaaa20cff28fdf01268d3604b/src/cascadia/TerminalApp/TerminalAppLib.vcxproj#L12-L17

This workaround likely became unnecessary some time before we added `TerminalSettingsEditor` :smile:
(Note: if you delete `TerminalApp/*.xaml`, everything continues to work. It would be ideal if we could remove them from the package, but... you know. The WAP packaging project is just _trouble_.)
FWIW this is also true for TerminalSettingsEditor

_from `makepri dump`_

```xml
<NamedResource name="KeyChordListener.xbf" uri="ms-resource://Microsoft.WindowsTerminalPreview/Files/Microsoft.Terminal.Settings.Editor/KeyChordListener.xbf">
	<Candidate type="EmbeddedData">
		<Base64Value>[Embedded Binary Data]</Base64Value>
	</Candidate>
</NamedResource>
```
(Let me know if closing this is the wrong resolution! I think the concern is addressed :smile:)

@DHowett I think it is fair to say the primary concern is addressed.  Terminal is already using the more efficient approach.  The only lingering thing would _maybe_ be to have a tracking issue to remove unnecessary .xaml files from the package because they're wasting a small amount of disk and network bandwidth.  That feels fairly low priority to me, though.

Fix patch:
diff --git a/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj b/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj
index 9aaffac83ee..b5274d09103 100644
--- a/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj
+++ b/src/cascadia/CascadiaPackage/CascadiaPackage.wapproj
@@ -135,6 +135,10 @@
       <!-- 16.3.0 - remove non-resources.pri PRI files since we just forced them back in. -->
       <AppxPackagePayload Remove="@(AppxPackagePayload)" Condition="'%(Extension)' == '.pri' and '%(Filename)' != 'resources'" />
       <AppxUploadPackagePayload Remove="@(AppxUploadPackagePayload)" Condition="'%(Extension)' == '.pri' and '%(Filename)' != 'resources'" />
+
+      <!-- Remove all of the xaml files, because we are using embedded xbf payloads (saves about 500kb on disk!) -->
+      <AppxPackagePayload Remove="@(AppxPackagePayload)" Condition="'%(Extension)' == '.xaml'" />
+      <AppxUploadPackagePayload Remove="@(AppxUploadPackagePayload)" Condition="'%(Extension)' == '.xaml'" />
     </ItemGroup>
   </Target>
 


Test patch: