Skip to content

[release/10.0.1xx] [dotnet] Use desktop MSBuild task assemblies in VS for all platforms - #25718

Merged
rolfbjarne merged 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-25662-release/10.0.1xx-2026-06-17
Jun 18, 2026
Merged

[release/10.0.1xx] [dotnet] Use desktop MSBuild task assemblies in VS for all platforms#25718
rolfbjarne merged 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-25662-release/10.0.1xx-2026-06-17

Conversation

@rolfbjarne

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.

Ref: #25418


Co-authored-by: Milos Kotlar kotlarmilos@gmail.com
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Backport of #25662.

… 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 17, 2026 16:59
@rolfbjarne
rolfbjarne enabled auto-merge (squash) June 17, 2026 17:00

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 ensures MSBuild tasks run in-process inside Visual Studio by forcing use of the desktop (netstandard2.0) task assemblies across all Apple platform SDKs, avoiding reliance on the separate .NET task host that fails on Windows ARM64 (MSB4216).

Changes:

  • Set _UseDesktopTaskAssemblies=true in Xamarin.Shared.Sdk.props when BuildingInsideVisualStudio is true.
  • Guard the shared setting with '$(_UseDesktopTaskAssemblies)' == '' so the iOS-specific earlier setting remains authoritative (and continues to drive CoreiOSSdkDirectory).

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

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

Pipeline on Agent
Hash: 8d262ac4286892acc518426114caac75f7d7fc2e [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #8d262ac] Build passed (Build packages) ✅

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

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #8d262ac] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 8d262ac4286892acc518426114caac75f7d7fc2e [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #8d262ac] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 175 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. [attempt 2] 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 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (iOS): All 16 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 16 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. 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
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 8d262ac4286892acc518426114caac75f7d7fc2e [PR build]

@rolfbjarne
rolfbjarne merged commit 015557e into release/10.0.1xx Jun 18, 2026
49 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/backport-pr-25662-release/10.0.1xx-2026-06-17 branch June 18, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants