Skip to content

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

Draft
rolfbjarne wants to merge 6 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 6 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

Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: 1efd75e312f84f8167c744633f0bc4988db52960 [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

✅ [PR Build #1efd75e] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 1efd75e312f84f8167c744633f0bc4988db52960 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@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: 1efd75e312f84f8167c744633f0bc4988db52960 [PR build]

@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 #1efd75e] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 1efd75e312f84f8167c744633f0bc4988db52960 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [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

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.PostBuildTest.ArchiveTest(iOS,"ios-arm64"): Could not find xcarchive output for /Users/builder/Library/Developer/Xcode/Archives/2026-06-22/MySimpleApp 6-22-26 7.34 PM.xca...
    • Xamarin.Tests.PostBuildTest.BuildIpaTest(iOS,"ios-arm64"): Could not find app output for /Users/builder/azdo/_work/1/s/macios/tests/dotnet/MySimpleApp/iOS/bin/Release/net10.0-ios/ios-ar...
    • Xamarin.Tests.PostBuildTest.GetApplicationArtifactsArchiveTest(i...: '/Users/builder/azdo/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.400-preview.0.26319.102/dotnet' failed with exit code 1
      F...
    • ... and 4 more

Html Report (VSDrops) Download

❌ dotnettests tests (MacCatalyst) [attempt 2]

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.PostBuildTest.ArchiveTest(MacCatalyst,"maccatalyst...: Could not find xcarchive output for /Users/builder/Library/Developer/Xcode/Archives/2026-06-22/MySimpleApp 6-22-26 7.32 PM.xca...
    • Xamarin.Tests.PostBuildTest.ArchiveTest(MacCatalyst,"maccatalyst...: Could not find xcarchive output for /Users/builder/Library/Developer/Xcode/Archives/2026-06-22/MySimpleApp 6-22-26 7.31 PM.xca...
    • Xamarin.Tests.PostBuildTest.BuildPackageTest("MySimpleApp",MacCa...: Could not find app output for /Users/builder/azdo/_work/2/s/macios/tests/dotnet/MySimpleApp/MacCatalyst/bin/Debug/net10.0-macc...
    • ... and 9 more

Html Report (VSDrops) Download

❌ dotnettests tests (macOS) [attempt 2]

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.PostBuildTest.ArchiveTest(MacOSX,"osx-arm64;osx-x6...: Could not find xcarchive output for /Users/builder/Library/Developer/Xcode/Archives/2026-06-22/MySimpleApp 6-22-26 7.29 PM 2.x...
    • Xamarin.Tests.PostBuildTest.ArchiveTest(MacOSX,"osx-x64"): Could not find xcarchive output for /Users/builder/Library/Developer/Xcode/Archives/2026-06-22/MySimpleApp 6-22-26 7.29 PM.xca...
    • Xamarin.Tests.PostBuildTest.BuildPackageTest("MySimpleApp",MacOS...: Could not find app output for /Users/builder/azdo/_work/1/s/macios/tests/dotnet/MySimpleApp/macOS/bin/Debug/net10.0-macos/MySi...
    • ... and 6 more

Html Report (VSDrops) Download

❌ dotnettests tests (tvOS) [attempt 2]

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.PostBuildTest.ArchiveTest(TVOS,"tvos-arm64"): Could not find xcarchive output for /Users/builder/Library/Developer/Xcode/Archives/2026-06-22/MySimpleApp 6-22-26 7.25 PM.xca...
    • Xamarin.Tests.PostBuildTest.BuildIpaTest(TVOS,"tvos-arm64"): Could not find app output for /Users/builder/azdo/_work/1/s/macios/tests/dotnet/MySimpleApp/tvOS/bin/Release/net10.0-tvos/tvos...
    • Xamarin.Tests.PostBuildTest.GetApplicationArtifactsIpaTest(TVOS,...: '/Users/builder/azdo/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.400-preview.0.26319.102/dotnet' failed with exit code 1
      F...
    • ... and 1 more

Html Report (VSDrops) Download

❌ monotouch tests (macOS) [attempt 2]

1 tests failed, 19 tests passed.

Failed tests

  • monotouch-test/macOS/Release (trimmable static registrar, NativeAOT): TimedOut (Execution timed out after 1200 seconds.
    Test run crashed)

Html Report (VSDrops) Download

❌ windows tests [attempt 2]

1 tests failed, 2 tests passed.

Failed tests

  • Remote .NET tests/Xamarin.Tests.PostBuildTest.BuildIpaOnRemoteWindowsTest(iOS,"ios-arm64"): Failed: Could not find ipa output for c:\AzDO_work\7\s\macios\tests\dotnet\MySimpleApp\iOS\bin\Release\net10.0-ios\ios-arm64\MySimpleApp.ipa. All outputs:

  • Remote .NET tests/Xamarin.Tests.PostBuildTest.ArchiveOnRemoteWindowsTest(iOS,"ios-arm64"): Failed: Expected one xcarchive output. All outputs:

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 (Multiple platforms): 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. [attempt 2] 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
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 20 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 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: 1efd75e312f84f8167c744633f0bc4988db52960 [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