[dotnet] Use desktop MSBuild task assemblies in VS for all platforms#25662
[dotnet] Use desktop MSBuild task assemblies in VS for all platforms#25662kotlarmilos wants to merge 1 commit into
Conversation
… 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>
There was a problem hiding this comment.
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=trueinXamarin.Shared.Sdk.propswhenBuildingInsideVisualStudio=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
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
✅ [PR Build #9bc8395] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #9bc8395] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #9bc8395] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [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
Html Report (VSDrops) Download ❌ introspection tests [attempt 3]1 tests failed, 5 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (macOS) [attempt 3]1 tests failed, 22 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Description
Building a MacCatalyst app inside Visual Studio on Windows ARM64 fails with:
Root cause
Inside Visual Studio, our MSBuild tasks should run in-process using the
netstandard2.0assemblies. This is controlled by the_UseDesktopTaskAssembliesproperty. When it is not set, the tasks instead use the.NETassemblies, which need a separate .NET task host. That task host does not work reliably from Visual Studio, and fails on Windows ARM64.#25417 set
_UseDesktopTaskAssembliesfor 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
_UseDesktopTaskAssembliesin the sharedXamarin.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 forCoreiOSSdkDirectory); the== ''guard makes the shared copy a no-op for iOS.Contributes to #25418