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
- Create an unpackaged WinUI 3 app with these csproj settings:
true
None
true
- Add at least one .xaml page with x:Class (e.g., MainWindow.xaml)
- Run dotnet publish -r win-x64 -c Release
- Compare the intermediate output and publish directories:
dir bin\Release...\win-x64*.xbf # files exist here
dir bin\Release...\win-x64\publish*.xbf # empty
- 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.
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
true
None
true
dir bin\Release...\win-x64*.xbf # files exist here
dir bin\Release...\win-x64\publish*.xbf # empty
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:
Also tested with .NET SDK 9.0.312 -- same behavior.