Skip to content

XBF files are copied to MSIX even though already embedded in PRI file when referencing library project #10308

@whiskhub

Description

@whiskhub

Describe the bug

When referencing a WinUI 3 class library containing XAML files in a WinUI 3 app, the resulting binary XAML files (xbf) are being packaged in the MSIX package, even though the files are already embedded in the pri file of the class library:

└── WinUI3_Xbf_Repro/
    ├── AppxBlockMap.xml
    ├── AppxManifest.xml
    ├── ClassLibrary1.dll
    ├── ClassLibrary1.pri  <--- already embeds XBFs
    ├── resources.pri
    ├── WinUI3_Xbf_Repro.dll
    ├── WinUI3_Xbf_Repro.exe
    ├── ...
    └── ClassLibrary1/
        ├── ResourceDictionary1.xbf  <--- unnecessary
        ├── ResourceDictionary2.xbf  <--- unnecessary
        └── ...

This causes unnecessary files in the MSIX, slowing down installation. Also, the entire folder structure and file paths of XAML files are easily visible for the basic user, which is undesirable. (It's clear that the app can be decompiled easily anyways).

Calling makepri.exe dump /if ClassLibrary1.pri also confirms the xbf files are really embedded:

<PriInfo>
	<ResourceMap name="ClassLibrary1" version="1.0" primary="true">
		<Qualifiers/>
		<ResourceMapSubtree name="Files">
			<ResourceMapSubtree name="ClassLibrary1">
				<NamedResource name="ResourceDictionary1.xbf" uri="ms-resource://ClassLibrary1/Files/ClassLibrary1/ResourceDictionary1.xbf">
					<Candidate type="EmbeddedData">
						<Base64Value>[Embedded Binary Data]</Base64Value>
					</Candidate>
				</NamedResource>
				<NamedResource name="ResourceDictionary2.xbf" uri="ms-resource://ClassLibrary1/Files/ClassLibrary1/ResourceDictionary2.xbf">
					<Candidate type="EmbeddedData">
						<Base64Value>[Embedded Binary Data]</Base64Value>
					</Candidate>
				</NamedResource>

Steps to reproduce the bug

Simple repro: https://github.com/whiskhub/WinUI3_Xbf_Repro

  1. Create blank WinUI 3 app
  2. Add blank WinUI 3 class library project to the solution
  3. Reference the library in the main app
  4. Add XAML files to the library project
  5. Build and compile the app
  6. In Visual Studio, select "Release" configuration
  7. In Visual Studio, use Package and Publish -> Create App Packages... to create a MSIX package for sideloading
  8. Sideload the MSIX file OR simply open it in a ZIP file viewer

The MSIX will contain a subfolder "ClassLibrary1" with a .xbf file for each XAML file in code. The MSIX will also contain a ClassLibrary1.pri file, which already contains the *.xbf file contents embedded.

Expected behavior

There are no *.xbf files in the MSIX output, as they are embedded in the .pri file already.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows 11 (24H2): Build 26100

Additional context

Specifying <DisableEmbeddedXbf>false</DisableEmbeddedXbf> did not make any difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageIssue needs to be triaged by the area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions