Skip to content

[2.0-experimental] Fix sparse-packaged apps unable to discover module-specific PRI files (#6376)#6493

Open
guimafelipe wants to merge 6 commits into
release/2.0-experimentalfrom
user/felipeda/cherry-6376-experimental
Open

[2.0-experimental] Fix sparse-packaged apps unable to discover module-specific PRI files (#6376)#6493
guimafelipe wants to merge 6 commits into
release/2.0-experimentalfrom
user/felipeda/cherry-6376-experimental

Conversation

@guimafelipe
Copy link
Copy Markdown
Contributor

Cherry-pick of #6376 into release/2.0-experimental.

…#6376)

* Fix sparse-packaged apps unable to discover module-specific PRI files

Sparse-packaged apps have package identity (via AddPackageByUriAsync) but
deploy resources as loose files next to the executable. GetDefaultPriFile()
determines isPackaged=true for these apps (since they have identity), causing
GetDefaultPriFileForCurentModule to pass "resources.pri" to
MrmGetFilePathFromName — which only searches for that exact filename,
skipping the [modulename].pri fallback that unpackaged apps receive.

When the "resources.pri" search fails for apps with identity, fall back to
the unpackaged discovery path (pass nullptr to MrmGetFilePathFromName) which
triggers the broader search including "[modulename].pri" derived via
PathCchRenameExtension from the process executable name.

If the fallback also fails, return the original HRESULT from the
"resources.pri" search so callers that check for specific errors
(e.g., ERROR_FILE_NOT_FOUND) are not broken.

Existing test coverage:
- DefaultResourceManagerWithExePri validates the nullptr fallback mechanism
- DefaultResourceManager validates error behavior when no PRI exists
- DefaultResourceManagerWithResourcePri validates the normal packaged path

A full sparse-app integration test requires actual sparse package
registration (AddPackageByUriAsync) which is beyond unit test scope.

Fixes: microsoft/microsoft-ui-xaml#10856

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address PR review: simplify flow, shorten comment, gate on file-not-found

* Add backward-compatibility comment on return hr

* Move backward-compat comment to fallback block for clarity

* Keep comment sentences on single lines

* Use existing IsResourceNotFound() helper instead of manual HRESULT checks

* Merge two-line comment into single line

Agent-Logs-Url: https://github.com/microsoft/WindowsAppSDK/sessions/ed36cfc6-52ad-414b-8e1a-dc16f413a97e

Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@guimafelipe guimafelipe marked this pull request as ready for review May 20, 2026 23:56
@guimafelipe
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Bug 62382643: gate the sparse PRI fallback with containment so
it can be rolled back if needed.
@guimafelipe guimafelipe force-pushed the user/felipeda/cherry-6376-experimental branch from 3feeeec to 8507dd5 Compare May 21, 2026 18:49
@guimafelipe
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@guimafelipe guimafelipe requested review from Scottj1s and agniuks May 21, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants