Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

When UseArtifactsOutput is enabled, $(IntermediateOutputPath) is absolute. Prepending $(MSBuildProjectDirectory) creates invalid nested paths like:

/project/src/MyApp/home/user/artifacts/obj/MyApp/Debug/net10.0-ios/xcode/

Changes

  • Removed $(MSBuildProjectDirectory)/ prefix from _XcodeProjectDefaultOutputPathRoot in Microsoft.MaciOS.Sdk.Xcode.targets to prevent path concatenation issues when IntermediateOutputPath is absolute
  • Modified CreateXcArchive.cs to call Path.GetFullPath() on OutputPath, DerivedDataPath, and PackageCachePath before using them in xcodebuild commands
  • Modified CreateXcFramework.cs to call Path.GetFullPath() on XcArchivePath and OutputPath before using them in xcodebuild commands

This dual approach ensures that:

  • The root cause in the MSBuild targets file is fixed by removing the problematic prefix
  • The C# task implementations provide defensive path handling by normalizing paths to absolute before use
  • When paths are relative (traditional builds), Path.GetFullPath() resolves them correctly relative to the current directory
  • When paths are already absolute (artifacts mode), Path.GetFullPath() returns them unchanged

Fixes #24222

Original prompt

This section details on the original issue you should resolve

<issue_title><XcodeProject> and artifacts folder fails</issue_title>
<issue_description>### Apple platform

No response

Framework version

net9.0-*

Affected platform version

All

Description

When using xcode project and artifacts, the xcode is put inside the project directory.

Steps to Reproduce

  1. Add <XcodeProject
  2. Enable artifacts
  3. Build
  4. Observe the files in <reporoot>src/AI/src/Essentials.AI/Users/matthew/Documents/GitHub/maui/artifacts/obj/Essentials.AI/Debug/net10.0-ios26.0

I see the

<_XcodeProjectDefaultOutputPathRoot>$(MSBuildProjectDirectory)/$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>

<_XcodeProjectDefaultOutputPathRoot>$(MSBuildProjectDirectory)/$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>

This should probably not have the $(MSBuildProjectDirectory) at the start. In the old way, the $(IntermediateOutputPath) was relative (but could be absolute), the artifacts way is absolute as it could be anywhere.

Did you find any workaround?

No

Build logs

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix Xcode project path issue in artifacts Fix XcodeProject output path when using artifacts folder Nov 12, 2025
Copilot AI requested a review from mattleibow November 12, 2025 02:41
Copilot finished work on behalf of mattleibow November 12, 2025 02:41
@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 self-assigned this Nov 17, 2025

<PropertyGroup>
<_XcodeProjectDefaultOutputPathRoot>$(MSBuildProjectDirectory)/$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>
<_XcodeProjectDefaultOutputPathRoot>$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>
Copy link
Member

Choose a reason for hiding this comment

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

@copilot change the tasks that use this property to make it a full path before using the value (in the task's C# code).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Modified CreateXcArchive.cs and CreateXcFramework.cs to call Path.GetFullPath() on the paths before using them. The targets file has been reverted to keep $(MSBuildProjectDirectory). Commit: ad5a54f

Copilot AI requested a review from rolfbjarne November 20, 2025 10:09
Copilot finished work on behalf of rolfbjarne November 20, 2025 10:09
@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.


<PropertyGroup>
<_XcodeProjectDefaultOutputPathRoot>$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>
<_XcodeProjectDefaultOutputPathRoot>$(MSBuildProjectDirectory)/$(IntermediateOutputPath)xcode/</_XcodeProjectDefaultOutputPathRoot>
Copy link
Member

Choose a reason for hiding this comment

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

@copilot this change is still needed, please put it back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Restored the removal of $(MSBuildProjectDirectory)/ prefix from the targets file while keeping the Path.GetFullPath() calls in the C# tasks. Both changes are now in place. Commit: bcefb10

Copilot AI requested a review from rolfbjarne November 21, 2025 08:02
Copilot finished work on behalf of rolfbjarne November 21, 2025 08:02
@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

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

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #bcefb10] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 122 tests passed 🎉

Tests counts

✅ 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 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 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: bcefb10803e2da35ff48dc7ac3080b7c38bafea8 [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

Development

Successfully merging this pull request may close these issues.

<XcodeProject> and artifacts folder fails

4 participants