Skip to content

[msbuild] Fix using .NET Core assemblies for MSBuild tasks within VS#25850

Draft
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/fix-dotnet-core-msbuild-tasks-in-vs
Draft

[msbuild] Fix using .NET Core assemblies for MSBuild tasks within VS#25850
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/fix-dotnet-core-msbuild-tasks-in-vs

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

The standard MSBuild task overrides (MakeDir, Copy, Delete, etc.) in Xamarin.Shared.targets exist to support remoting from VS/Windows to a Mac. Previously, they shared the same Runtime and AssemblyFile as our custom tasks (via _TaskRuntime/_TaskAssemblyName), which meant when _TaskRuntime='NET', these standard task overrides would also try to use the .NET task host. This caused MSB4216 errors in Visual Studio because VS couldn't reliably create the .NET task host process (especially on Windows ARM64).

The fix introduces separate properties (_RemotingTaskRuntime and _RemotingTaskAssemblyName) for these standard task overrides, which always use the netstandard2.0 assembly with CurrentRuntime. This lets them run in-process without requiring the task host, while our custom tasks (Xamarin.MacDev.Tasks.*) continue to use the .NET Core assemblies via the task host as intended.

With this fix, the _UseDesktopTaskAssemblies workaround that forced ALL tasks to use netstandard2.0 when building inside Visual Studio is no longer needed and has been removed. The property is still honored as an escape hatch if explicitly set.

Fixes #25418

The standard MSBuild task overrides (MakeDir, Copy, Delete, etc.) in
Xamarin.Shared.targets exist to support remoting from VS/Windows to a Mac.
Previously, they shared the same Runtime and AssemblyFile as our custom tasks
(via _TaskRuntime/_TaskAssemblyName), which meant when _TaskRuntime='NET',
these standard task overrides would also try to use the .NET task host. This
caused MSB4216 errors in Visual Studio because VS couldn't reliably create
the .NET task host process (especially on Windows ARM64).

The fix introduces separate properties (_RemotingTaskRuntime and
_RemotingTaskAssemblyName) for these standard task overrides, which always
use the netstandard2.0 assembly with CurrentRuntime. This lets them run
in-process without requiring the task host, while our custom tasks
(Xamarin.MacDev.Tasks.*) continue to use the .NET Core assemblies via the
task host as intended.

With this fix, the _UseDesktopTaskAssemblies workaround that forced ALL
tasks to use netstandard2.0 when building inside Visual Studio is no longer
needed and has been removed. The property is still honored as an escape
hatch if explicitly set.

Fixes #25418

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [PR Build #639c0e0] Build failed (Detect API changes) 🔥

Build failed for the job 'Detect API changes' (with job status 'Failed')

Pipeline on Agent
Hash: 639c0e05b35f457e60ce8d0e673732ee77e7f8aa [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: 639c0e05b35f457e60ce8d0e673732ee77e7f8aa [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [PR Build #639c0e0] Build failed (Build macOS tests) 🔥

Build failed for the job 'Build macOS tests' (with job status 'Failed')

Pipeline on Agent
Hash: 639c0e05b35f457e60ce8d0e673732ee77e7f8aa [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #639c0e0] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 639c0e05b35f457e60ce8d0e673732ee77e7f8aa [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #639c0e0] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

5 tests crashed, 1 tests failed, 173 tests passed.

Failures

❌ windows tests

1 tests failed, 2 tests passed.

Failed tests

  • Remote .NET tests/Xamarin.Tests.WindowsTest.PluralRuntimeIdentifiersWithRemoteMac(iOS,"iossimulator-arm64;iossimulator-x64"): Failed: 'dotnet build' timed out after 00:10:00

  • Remote .NET tests/Xamarin.Tests.WindowsTest.StripTest(iOS,"ios-arm64","Release"): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.DotNetProjectTest.AppWithLibraryWithResourcesReferenceOnRemoteWindows(iOS,"ios-arm64",True): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.WindowsTest.BuildEmbeddedFrameworkInBindingProjectApp(iOS,"iossimulator-arm64"): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.WindowsTest.BundleStructureWithRemoteMac(iOS,"ios-arm64",All,"Debug"): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.IncrementalBuildTest.CodeChangeSkipsTargetsOnRemoteWindows(iOS,"iossimulator-arm64",True): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.PostBuildTest.BuildIpaAndArchiveOnRemoteWindowsTest(iOS,"ios-arm64"): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.DotNetProjectTest.AppWithLibraryWithResourcesReferenceOnRemoteWindows(iOS,"ios-arm64",False): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.DotNetProjectTest.BuildProjectsWithExtensionsOnRemoteWindows(iOS,"ios-arm64",False): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.WindowsTest.PluralRuntimeIdentifiersWithRemoteMac(iOS,"ios-arm64"): Failed: 'dotnet build' timed out after 00:10:00

  • Remote .NET tests/Xamarin.Tests.WindowsTest.RemoteTest(iOS,"ios-arm64"): Failed: 'dotnet build' failed with exit code 1

  • Remote .NET tests/Xamarin.Tests.IncrementalBuildTest.CodeChangeSkipsTargetsOnRemoteWindows(iOS,"iossimulator-arm64",False): Failed: 'dotnet build' failed with exit code 1

Html Report (VSDrops) Download

❌ Tests on macOS Monterey (12) tests

🔥 Failed catastrophically on VSTS: test results - mac_monterey (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Ventura (13) tests

🔥 Failed catastrophically on VSTS: test results - mac_ventura (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Sonoma (14) tests

🔥 Failed catastrophically on VSTS: test results - mac_sonoma (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Sequoia (15) tests

🔥 Failed catastrophically on VSTS: test results - mac_sequoia (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

🔥 Failed catastrophically on VSTS: test results - mac_tahoe (no summary found).

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ 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 (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 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

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 639c0e05b35f457e60ce8d0e673732ee77e7f8aa [PR build]

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix using .NET Core assemblies for MSBuild tasks within VS

2 participants