microsoft / microsoft/WindowsAppSDK

NativeAOT publish does not include .xbf and .pri files in output directory

Open
#6,394 2 comments 4 reactions 1 assignee View on GitHub

@guimafelipe is already working on this.

Since May 4, 2026.

area-AOT Status: In-Progress
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

When publishing a WinUI 3 project with PublishAot=true and WindowsPackageType=None, the compiled XAML binary files (.xbf) and the package resource index (.pri) are generated in the intermediate build output but not copied to the publish directory.

This causes Application.LoadComponent() to crash silently (exit code 0, no error output) because ms-appx:/// URI resolution cannot find the XAML resources.

### Steps to reproduce the bug

1. Create an unpackaged WinUI 3 app with these csproj settings:
```
true
None
true
```
2. Add at least one .xaml page with x:Class (e.g., MainWindow.xaml)
3. Run `dotnet publish -r win-x64 -c Release`
4. Compare the intermediate output and publish directories:
dir bin\Release\...\win-x64\*.xbf # files exist here
dir bin\Release\...\win-x64\publish\*.xbf # empty
5. Run the published exe -- it exits immediately with code 0, no error

For a full repro, see the deblasis/ghostty fork:
- Before fix (crash): deblasis/ghostty@57efcc469844167f2320ecad40ea8aa02c8e442a
- After fix (workaround): deblasis/ghostty@5c12648d19d59d3f827b6de33d36f00672b65450
- Branch: https://github.com/deblasis/ghostty/tree/windows-nativeaot
- The workaround is a post-publish MSBuild target in https://github.com/deblasis/ghostty/blob/windows-nativeaot/windows/Ghostty/Ghostty.csproj

### Expected behavior

The publish step should copy .xbf files (preserving subdirectory structure) and the $(AssemblyName).pri file to the publish output directory, matching non-AOT publish behavior.

### Screenshots

_No response_

### NuGet package version

1.6.250602001

### Packaging type

Unpackaged

### Windows version

_No response_

### IDE

Other

### Additional context

Windows version: Windows 11 version 24H2 LTSC (26100, June Update)

IDE: Other (dotnet CLI / .NET SDK 10.0.201)

Additional context:

Workaround MSBuild target:
```

<_XamlResources Include="$(OutputPath)**\*.xbf" />
<_XamlResources Include="$(OutputPath)$(AssemblyName).pri" />

```
Also tested with .NET SDK 9.0.312 -- same behavior.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.