Skip to content

[msbuild] Improve how we handle the path to Xcode.#24021

Open
rolfbjarne wants to merge 7 commits intomainfrom
dev/rolf/msbuild-sdkdevpath
Open

[msbuild] Improve how we handle the path to Xcode.#24021
rolfbjarne wants to merge 7 commits intomainfrom
dev/rolf/msbuild-sdkdevpath

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Oct 16, 2025

  • Add support for an MSBuild property ('XcodeLocation') to set the Xcode location.
  • Use a new facility in macios-devtools (the 'XcodeLocator' class) to find Xcode. This required a bump to the corresponding submodule.
  • Deprecate the file-based locations.
  • Always set DEVELOPER_DIR when executing subprocesses.
  • Don't use static state to store the Xcode location. This fixes a problem where the static state would remain in memory when MSBuild's build server is being used, and then we'd do the wrong thing when building a different project using a different version of Xcode.

Misc improvements:

This will hopefully remove some confusion about which Xcode is being used; now we just look at the system's Xcode, unless it's overridden by the MSBuild property 'XcodeLocation'.

Fixes #3931.
Fixes #11172.
Fixes #21762.

@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

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.

@rolfbjarne rolfbjarne marked this pull request as ready for review January 31, 2026 01:10
@rolfbjarne rolfbjarne requested a review from Copilot January 31, 2026 01:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates Xcode discovery and configuration away from static, file-based mechanisms and the MD_APPLE_SDK_ROOT environment variable to a new XcodeLocator-based flow, driven primarily by the XcodeLocation MSBuild property and DEVELOPER_DIR. It updates tasks, tests, and documentation to align with the new behavior and deprecation plan.

Changes:

  • Introduce XcodeLocator usage into XamarinTask/DetectSdkLocation and wire SdkDevPath through MSBuild targets, removing the static Sdks helper.
  • Replace MD_APPLE_SDK_ROOT usage with DEVELOPER_DIR/XcodeLocation across build scripts and tests, and add deprecation warnings for the old environment variable and settings files.
  • Update tests and docs to validate the new Xcode selection behavior and reflect the new configuration options.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/xharness/Jenkins/TestTasks/AppleTestTask.cs Switch test harness env var from MD_APPLE_SDK_ROOT to DEVELOPER_DIR.
tests/package-mac-tests.sh Update packaging script to export DEVELOPER_DIR instead of MD_APPLE_SDK_ROOT.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/IBToolTaskTests.cs Update IBTool tests to use CurrentSdk instead of the removed static Sdks helper and shared execution helper.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_tvOS.cs Use Task.CurrentSdk for tvOS default SDK version resolution.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_iOS.cs Use Task.CurrentSdk for iOS default SDK version resolution.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs Ensure TargetFrameworkMoniker is set based on Platform in core plist tests.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileAppManifestTaskTests.cs Adjust CompileAppManifest tests to use CurrentSdk for installed SDK versions.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ACToolTaskTest.cs Update ACTool tests to create the task earlier and avoid Sdks.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/AssemblySetup.cs Use DEVELOPER_DIR instead of MD_APPLE_SDK_ROOT in MSBuild test setup.
tests/dotnet/UnitTests/XcodeVersionTest.cs Drive Xcode selection via the XcodeLocation MSBuild property instead of MD_APPLE_SDK_ROOT.
tests/common/Configuration.cs Set DEVELOPER_DIR instead of MD_APPLE_SDK_ROOT in common test build environment.
tests/common/BinLog.cs Filter out deprecation noise from settings-file-related warnings in binlog parsing.
msbuild/Xamarin.Shared/Xamarin.Shared.targets Thread SdkDevPath into tasks and pass XcodeLocation into DetectSdkLocations.
msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs Add XcodeLocator and CurrentSdk instance-level handling and improve logging signatures.
msbuild/Xamarin.MacDev.Tasks/Tasks/ReadAppManifest.cs Use CurrentSdk for Mac Catalyst iOS-version conversion.
msbuild/Xamarin.MacDev.Tasks/Tasks/DetectSigningIdentity.cs Resolve codesign_allocate via CurrentSdk.DeveloperRoot.
msbuild/Xamarin.MacDev.Tasks/Tasks/DetectSdkLocation.cs Rework SDK detection to use XcodeLocator, emit deprecation warnings, and rely on CurrentSdk.
msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlements.cs Resolve default entitlements path via CurrentSdk.
msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs Use CurrentSdk and XcodeLocator when validating SDKs and populating Xcode-related plist keys.
msbuild/Xamarin.MacDev.Tasks/Sdks.cs Remove the static Sdks helper in favor of instance-based CurrentSdk.
msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx Add new warning/error messages for Xcode detection and deprecations.
external/Xamarin.MacDev Bump Xamarin.MacDev submodule to gain XcodeLocator support.
docs/building-apps/build-properties.md Document the new XcodeLocation build property and Xcode resolution precedence.
Make.config Stop exporting MD_APPLE_SDK_ROOT at the root make level in favor of DEVELOPER_DIR.

@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
Collaborator

✅ [CI Build #f9b9cfc] Build passed (Build packages) ✅

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
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: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #f9b9cfc] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #f9b9cfc] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #f9b9cfc] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #f9b9cfc] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #f9b9cfc] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #f9b9cfc] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #f9b9cfc] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

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

Failures

❌ monotouch tests (MacCatalyst)

1 tests failed, 10 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Release (interpreter): Failed (Test run crashed (exit code: 255).
    Test run crashed)

Html Report (VSDrops) Download

Successes

✅ 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: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 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

Pipeline on Agent
Hash: f9b9cfcc3127b7cdcab80284bfac19f6accfcc6c [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants

Comments