Skip to content

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

@deblasis

Description

@deblasis

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:

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:

<Target Name="CopyXamlResourcesForAot" AfterTargets="Publish"
        Condition="'$(PublishAot)' == 'true'">
<ItemGroup>
    <_XamlResources Include="$(OutputPath)**\*.xbf" />
    <_XamlResources Include="$(OutputPath)$(AssemblyName).pri" />
</ItemGroup>
<Copy SourceFiles="@(_XamlResources)"
        DestinationFiles="@(_XamlResources->'$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')"
        SkipUnchangedFiles="true" />
</Target>

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions