Skip to content

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

Draft
rolfbjarne wants to merge 8 commits into
mainfrom
dev/rolf/issue-23898-test
Draft

[msbuild] Resolve Content and BundleResource items using the main project's location. Fixes 23898.#25713
rolfbjarne wants to merge 8 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>
@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.

@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 #1e74079] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 1e74079201b9951c305180514c1c80d9bad9edbe [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #1e74079] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 1e74079201b9951c305180514c1c80d9bad9edbe [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: 1e74079201b9951c305180514c1c80d9bad9edbe [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: 1e74079201b9951c305180514c1c80d9bad9edbe [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #1e74079] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 1 tests failed, 198 tests passed.

Failures

❌ linker tests (macOS)

1 tests failed, 20 tests passed.

Failed tests

  • link all/macOS/Debug (PrepareAssemblies, CoreCLR, Trimmable Static Registrar): HarnessException (Harness exception for 'link all': System.Exception: Unable to evaluate the property OutputPath in /Users/cloudtest/vss/_work/1/s/macios/tests/xharness/bin/Debug/tmp-test-dir/link all474/link all.csproj, build failed with exit code 139. Timed out: False
    at Xharness.AppBundleLocator.GetPropertyByMSBuildEvaluationAsync(XmlDocument csproj, String projectPath, String evaluateProperty, String dependsOnTargets, Dictionary`2 properties) in /Users/cloudtest/vss/_work/1/s/macios/tests/xharness/AppBundleLocator.cs:line 123
    at Xharness.AppBundleLocator.LocateAppBundle(XmlDocument projectFile, String projectFilePath, TestTarget target, String buildConfiguration) in /Users/cloudtest/vss/_work/1/s/macios/tests/xharness/AppBundleLocator.cs:line 48
    at Xharness.Jenkins.TestTasks.MacExecuteTask.RunTestAsync() in /Users/cloudtest/vss/_work/1/s/macios/tests/xharness/Jenkins/TestTasks/MacExecuteTask.cs:line 52
    at Xharness.Jenkins.TestTasks.RunTest.ExecuteAsync() in /Users/cloudtest/vss/_work/1/s/macios/tests/xharness/Jenkins/TestTasks/RunTest.cs:line 113
    at Xharness.Jenkins.TestTasks.TestTask.RunInternalAsync() in /Users/cloudtest/vss/_work/1/s/macios/tests/xharness/Jenkins/TestTasks/TestTask.cs:line 234)

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: 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 (tvOS): All 15 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
✅ xtro: All 1 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: 1e74079201b9951c305180514c1c80d9bad9edbe [PR build]

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

2 participants