Skip to content

[dotnet] Use desktop MSBuild task assemblies in VS for all platforms#25662

Open
kotlarmilos wants to merge 1 commit into
mainfrom
dev/kotlarmilos/fix-maccatalyst-taskhost-arm64
Open

[dotnet] Use desktop MSBuild task assemblies in VS for all platforms#25662
kotlarmilos wants to merge 1 commit into
mainfrom
dev/kotlarmilos/fix-maccatalyst-taskhost-arm64

Conversation

@kotlarmilos

@kotlarmilos kotlarmilos commented Jun 9, 2026

Copy link
Copy Markdown
Member

Description

Building a MacCatalyst app inside Visual Studio on Windows ARM64 fails with:

error MSB4216: Could not run the "MakeDir" task because MSBuild could not create
or connect to a task host with runtime "NET" and architecture "*".

Root cause

Inside Visual Studio, our MSBuild tasks should run in-process using the netstandard2.0 assemblies. This is controlled by the _UseDesktopTaskAssemblies property. When it is not set, the tasks instead use the .NET assemblies, which need a separate .NET task host. That task host does not work reliably from Visual Studio, and fails on Windows ARM64.

#25417 set _UseDesktopTaskAssemblies for Visual Studio builds, but only in the iOS SDK. MacCatalyst, macOS and tvOS were missed, so they still try to use the .NET task host and break.

Fix

Set _UseDesktopTaskAssemblies in the shared Xamarin.Shared.Sdk.props, which is imported by all four platforms, so the workaround applies everywhere. The iOS SDK keeps setting it earlier (it also needs it for CoreiOSSdkDirectory); the == '' guard makes the shared copy a no-op for iOS.

Contributes to #25418

… not just iOS

When building inside Visual Studio on Windows, our MSBuild tasks (including
the built-in tasks we override, such as MakeDir) were registered with
Runtime="NET" and the net assemblies for every platform except iOS. That
requires MSBuild to spin up a .NET task host, which doesn't work reliably -
in particular it fails on Windows ARM64 with:

  error MSB4216: Could not run the "MakeDir" task because MSBuild could not
  create or connect to a task host with runtime "NET" and architecture "*".

#25417 worked around this for iOS by setting _UseDesktopTaskAssemblies=true
(which selects the netstandard2.0 task assemblies and Runtime=CurrentRuntime,
so the tasks run in-process) inside VS, but it only added the property to
Microsoft.iOS.Sdk.props. MacCatalyst, macOS and tvOS were left out, so a
net*-maccatalyst project still failed to build in VS on Windows ARM64.

Move the property into the shared Xamarin.Shared.Sdk.props (imported by all
four platform SDKs) so the workaround applies everywhere. The iOS Sdk.props
keeps setting it earlier because it also drives CoreiOSSdkDirectory, and the
'== ' guard makes the shared copy idempotent.

Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/3013050
Ref: #25418

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 09:10
@kotlarmilos kotlarmilos changed the title [dotnet] Use desktop MSBuild task assemblies in VS for all platforms, not just iOS [dotnet] Use desktop MSBuild task assemblies in VS for all platforms Jun 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes Visual Studio (Windows ARM64) build failures for non‑iOS Apple platform projects by ensuring MSBuild uses the in-proc “desktop” (netstandard2.0) task assemblies when building inside Visual Studio, instead of the Runtime="NET" task host path that can fail (MSB4216).

Changes:

  • Set _UseDesktopTaskAssemblies=true in Xamarin.Shared.Sdk.props when BuildingInsideVisualStudio=true (idempotent if already set by a platform SDK).
  • Extend the existing iOS-specific workaround to also cover Mac Catalyst, macOS, and tvOS builds in VS.
Show a summary per file
File Description
dotnet/targets/Xamarin.Shared.Sdk.props Enables desktop/netstandard2.0 MSBuild task assemblies in Visual Studio builds across all Apple platform SDKs.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@kotlarmilos kotlarmilos requested a review from rolfbjarne June 9, 2026 09:14
@kotlarmilos kotlarmilos self-assigned this Jun 9, 2026
@dalexsoto

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: 9bc8395fddd7ecbec4d6058855358d31735e4ce5 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #9bc8395] Build passed (Build packages) ✅

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

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #9bc8395] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 9bc8395fddd7ecbec4d6058855358d31735e4ce5 [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

🔥 [CI Build #9bc8395] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 5 tests failed, 188 tests passed.

Failures

❌ fsharp tests [attempt 3]

2 tests failed, 2 tests passed.

Failed tests

  • fsharp/iOS - simulator/Debug: TimedOut
  • fsharp/tvOS - simulator/Debug: LaunchTimedOut

Html Report (VSDrops) Download

❌ introspection tests [attempt 3]

1 tests failed, 5 tests passed.

Failed tests

  • introspection/macOS/Debug: Failed (Test run failed.
    Tests run: 34 Passed: 33 Inconclusive: 0 Failed: 1 Ignored: 0)

Html Report (VSDrops) Download

❌ monotouch tests (macOS) [attempt 3]

1 tests failed, 22 tests passed.

Failed tests

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

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

1 tests failed, 4 tests passed.

Failed tests

  • monotouch-test: Failed (exit code 2)
    • No test failure details available. stderr output:
      • 2026-06-09 09:18:45.183 monotouchtest[16769:19998201] [PASS] VeryGeneric
      • 2026-06-09 09:18:45.184 monotouchtest[16769:19998201] [PASS] WrapperTypeLookupTest
      • 2026-06-09 09:18:45.184 monotouchtest[16769:19998201] Xamarin.Tests.RuntimeTest : 345.5043 ms
      • 2026-06-09 09:18:45.184 monotouchtest[16769:19998201] Xamarin.Tests : 345.5567 ms
      • 2026-06-09 09:18:45.184 monotouchtest[16769:19998201] Xamarin : 352.8956 ms
      • 2026-06-09 09:18:45.185 monotouchtest[16769:19998201] bindings-test : 352.9546 ms
      • 2026-06-09 09:18:45.189 monotouchtest[16769:19997100] Tests run: 3618 Passed: 3608 Inconclusive: 10 Failed: 0 Ignored: 152
      • 2026-06-09 09:18:45.190 monotouchtest[16769:19997100] AutoRun (): completed test run on main thread
      • 2026-06-09 09:18:45.190 monotouchtest[16769:19997100] Exiting test run with success
      • make: *** [exec-monotouch-test] Error 1

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. [attempt 2] 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
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker (iOS): All 11 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 20 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 23 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 20 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. [attempt 2] 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

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 9bc8395fddd7ecbec4d6058855358d31735e4ce5 [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.

4 participants