[msbuild] Resolve Content and BundleResource items using the main project's location. Fixes 23898.#25713
[msbuild] Resolve Content and BundleResource items using the main project's location. Fixes 23898.#25713rolfbjarne wants to merge 6 commits into
Conversation
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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #1efd75e] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #1efd75e] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #1efd75e] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build #1efd75e] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 6 tests failed, 201 tests passed. Failures❌ dotnettests tests (iOS) [attempt 2]1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst) [attempt 2]1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (macOS) [attempt 2]1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (tvOS) [attempt 2]1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (macOS) [attempt 2]1 tests failed, 19 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests [attempt 2]1 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
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