Skip to content

[msbuild] Resolve Content and BundleResource items using the main project's location. Fixes 23898.#25713

Merged
rolfbjarne merged 12 commits into
mainfrom
dev/rolf/issue-23898-test
Jul 3, 2026
Merged

[msbuild] Resolve Content and BundleResource items using the main project's location. Fixes 23898.#25713
rolfbjarne merged 12 commits into
mainfrom
dev/rolf/issue-23898-test

Conversation

@rolfbjarne

@rolfbjarne rolfbjarne commented Jun 17, 2026

Copy link
Copy Markdown
Member

Always compute the LogicalName for Content and BundleResource items relative to the project file (LocalMSBuildProjectFullPath) instead of the defining project file (LocalDefiningProjectFullPath). This fixes the issue where SDKs (like the Razor SDK) that add Content items from a directory far from the project would produce nonsensical paths like '../../../../../src/MyProject/file.png' that get rejected.

Fixes #23898

🤖 Pull request created by Copilot

Add a test that reproduces the issue where Content/BundleResource items
defined by an SDK (like the Razor SDK) have their LogicalName computed
relative to the SDK directory instead of the project directory, resulting
in paths like '../../../../../src/MyProject/file.png' that get rejected.

This test currently fails, demonstrating the bug described in #23898.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…s location. Fixes #23898.

Always compute the LogicalName for Content and BundleResource items
relative to the project file (LocalMSBuildProjectFullPath) instead of
the defining project file (LocalDefiningProjectFullPath). This fixes
the issue where SDKs (like the Razor SDK) that add Content items
from a directory far from the project would produce nonsensical paths
like '../../../../../src/MyProject/file.png' that get rejected.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…10/11, opt-out for .NET 12+

Add a new MSBuild property ResolveResourceItemsRelativeToProject that
controls whether Content and BundleResource items have their LogicalName
computed relative to the project file (new behavior) or the defining
project file (legacy behavior).

- .NET 10 and .NET 11: defaults to false (opt-in)
- .NET 12+: defaults to true (opt-out)

The property is passed through a new IHasResolveResourceItemsRelativeToProject
interface so that GetVirtualProjectPath can check the flag without changing
its generic constraints.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…ode paths

Test with ResolveResourceItemsRelativeToProject=true (.NET 12+ default)
and ResolveResourceItemsRelativeToProject=false (.NET 10/11 default) to
ensure both the fixed and legacy behaviors are covered.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rolfbjarne rolfbjarne removed the request for review from mauroa July 2, 2026 14:18
The default 'false' applies to any TargetFrameworkVersion below 12.0,
not just .NET 10 and .NET 11. Update comments and documentation to
say '< .NET 12' for accuracy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rolfbjarne and others added 2 commits July 2, 2026 16:24
…in .NET 13+

Enforce the 'permanently enabled in .NET 13+' policy with a build error
if someone explicitly sets the property to false. This ensures the
breaking change is enforced rather than just documented.

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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #2168897] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 2168897f7a23d68499ef80fdde69419023dd8cc0 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #2168897] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 2168897f7a23d68499ef80fdde69419023dd8cc0 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #2168897] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

2 tests crashed, 1 tests failed, 182 tests passed.

Failures

❌ cecil tests

🔥 Failed catastrophically on VSTS: test results - cecil (no summary found).

Html Report (VSDrops) Download

❌ linker tests (tvOS)

🔥 Failed catastrophically on VSTS: test results - linker_tvos (no summary found).

Html Report (VSDrops) Download

❌ xtro tests

1 tests failed, 0 tests passed.

Failed tests

  • Xtro: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.Xtro.RunTest: ExitCode
      Assert.That(rv, Is.EqualTo (0))
      Expected: 0
      But was: 2

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 2168897f7a23d68499ef80fdde69419023dd8cc0 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) July 3, 2026 11:06
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #2168897] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 2168897f7a23d68499ef80fdde69419023dd8cc0 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 2168897f7a23d68499ef80fdde69419023dd8cc0 [PR build]

@rolfbjarne rolfbjarne merged commit 41d33d3 into main Jul 3, 2026
57 checks passed
@rolfbjarne rolfbjarne deleted the dev/rolf/issue-23898-test branch July 3, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content and BundleResource items are resolved using the defining project's location

4 participants