Fix UWP XBF files losing subdirectory paths in resources.pri when UseArtifactsOutput is enabled#53867
Fix UWP XBF files losing subdirectory paths in resources.pri when UseArtifactsOutput is enabled#53867
Conversation
…ArtifactsOutput is enabled Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/4d3dd462-6363-4288-8aca-ceaf03eb3e26 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
… PropertyGroup Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/4d3dd462-6363-4288-8aca-ceaf03eb3e26 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
|
@copilot can you add a test for this? |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect resource path computation for UWP-generated XBF files when UseArtifactsOutput=true moves IntermediateOutputPath outside the project directory, preventing subdirectory paths from being dropped in resources.pri.
Changes:
- Adds a new MSBuild target (
_FixGeneratedXbfFilesLink) that runs afterMarkupCompilePass2forUseUwp=true. - For
_GeneratedXbfFilesoutside the project directory, setsLinkto the path relative to$(IntermediateOutputPath)to preserve subdirectory structure.
…tput is enabled Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/89b95d8b-f70d-4b67-9b72-de499eb167cc Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Added a regression test in commit c51802b: The test creates a |
When
UseUwp=trueandUseArtifactsOutput=true, theIntermediateOutputPathmoves outside the project directory. The AppX Package Targets compute PRI paths for_GeneratedXbfFilesusing%(Filename)%(Extension)for items outside the project directory, dropping subdirectory prefixes (e.g.,Styles.xbfinstead ofResources\Styles.xbf), causing runtimeXamlParseException.Changes
Microsoft.NET.Windows.targets: Adds_FixGeneratedXbfFilesLinktarget that runsAfterTargets="MarkupCompilePass2"whenUseUwp=true. For any_GeneratedXbfFilesitem outside the project directory (the artifacts case), setsLinkto the path relative to$(IntermediateOutputPath):This ensures
Resources\Styles.xbfis correctly emitted intoresources.prirather than justStyles.xbf, matching what the XAML compiler-generated code-behind references viams-appx:///Resources/Styles.xaml.GivenThatWeWantToBuildAWindowsDesktopProject.cs: Adds regression testItSetsCorrectLinkMetadataOnGeneratedXbfFilesWhenUsingArtifactsOutputthat creates a UWP project withUseArtifactsOutput=true, injects simulated_GeneratedXbfFilesitems in subdirectories of$(IntermediateOutputPath), and verifies that the_FixGeneratedXbfFilesLinktarget correctly setsLinkmetadata to preserve the subdirectory structure (e.g.,Resources\Styles.xbfandViews\Home.xbf).