Add TaskFactory="TaskHostFactory" Runtime="NET" to xa-prep-tasks and BootstrapTasks UsingTask elements - #10893
Merged
Conversation
…and BootstrapTasks UsingTask elements This runs internal build-time tasks in a separate process to avoid Windows file locking issues, and ensures they run on .NET even when MSBuild.exe in Visual Studio uses .NET Framework. Shipped product UsingTask elements are intentionally NOT modified. Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Windows file locking for xa-prep-tasks and BootstrapTasks
Add TaskFactory="TaskHostFactory" Runtime="NET" to xa-prep-tasks and BootstrapTasks UsingTask elements
Mar 5, 2026
jonathanpeppers
marked this pull request as ready for review
March 6, 2026 00:07
jonathanpeppers
requested review from
grendello,
jonathanpeppers and
simonrozsival
as code owners
March 6, 2026 00:07
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds TaskFactory="TaskHostFactory" Runtime="NET" attributes to all internal build-time <UsingTask/> elements that reference $(PrepTasksAssembly) (xa-prep-tasks) or $(BootstrapTasksAssembly), to run these tasks out-of-process and avoid Windows file locking issues when MSBuild loads the task assembly DLLs in-process.
Changes:
- Added
TaskFactory="TaskHostFactory" Runtime="NET"to all 42<UsingTask/>elements referencing internal build task assemblies across 16 target/project files - Updated
.github/copilot-instructions.mdwith guidance for future task additions, including a clear note to NOT apply this to shipped product UsingTask elements
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.github/copilot-instructions.md |
Added documentation for the TaskHostFactory convention on internal build tasks |
build-tools/scripts/TestApks.targets |
Updated 15 UsingTask elements (BootstrapTasks + PrepTasks) |
build-tools/scripts/XAVersionInfo.targets |
Updated 6 UsingTask elements (PrepTasks Git-related tasks) |
build-tools/installers/create-installers.targets |
Updated 1 UsingTask element (PrepTasks ReplaceFileContents) |
build-tools/create-packs/Directory.Build.targets |
Updated 1 UsingTask element (PrepTasks ReplaceFileContents) |
build-tools/create-packs/Microsoft.NET.Sdk.Android.proj |
Updated 1 UsingTask element (PrepTasks ReplaceFileContents) |
build-tools/create-packs/Microsoft.Android.Sdk.proj |
Updated 1 UsingTask element (BootstrapTasks GenerateUnixFilePermissions) |
build-tools/create-android-api/create-android-api.csproj |
Updated 1 UsingTask element (BootstrapTasks RunParallelCmds) |
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets |
Updated 5 UsingTask elements (BootstrapTasks + PrepTasks) |
src/Mono.Android/Mono.Android.targets |
Updated 3 UsingTask elements (PrepTasks + BootstrapTasks) |
src/Mono.Android.Runtime/Mono.Android.Runtime.csproj |
Updated 1 UsingTask element (PrepTasks ReplaceFileContents) |
src/aapt2/aapt2.targets |
Updated 2 UsingTask elements (PrepTasks + BootstrapTasks) |
src/bundletool/bundletool.targets |
Updated 1 UsingTask element (PrepTasks DownloadUri) |
src/native/native.targets |
Updated 1 UsingTask element (BootstrapTasks RunParallelCmds) |
src/native/common/libunwind/libunwind-xamarin.targets |
Updated 1 UsingTask element (BootstrapTasks RunParallelCmds) |
tests/api-compatibility/api-compatibility.targets |
Updated 1 UsingTask element (BootstrapTasks Zip) |
tests/CodeGen-Binding/.../Xamarin.Android.LibraryProjectZip-LibBinding.targets |
Updated 1 UsingTask element (PrepTasks ReplaceFileContents) |
grendello
approved these changes
Mar 6, 2026
jonathanpeppers
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows file locking on task assembly DLLs causes build failures when MSBuild loads
xa-prep-tasksandBootstrapTasksin-process. Running them out-of-process viaTaskHostFactoryavoids the lock, andRuntime="NET"ensures they run on .NET even under MSBuild.exe (.NET Framework) in Visual Studio.Changes
TaskFactory="TaskHostFactory" Runtime="NET"to all 42<UsingTask/>elements referencing$(PrepTasksAssembly)or$(BootstrapTasksAssembly)across 16 files<UsingTask/>elements (Xamarin.Android.Common.targets,Microsoft.Android.Sdk/*.targets, etc.) — these would affect customer builds.github/copilot-instructions.mdwith guidance for future task additionsExample
Before:
After:
Reference: https://github.com/rainersigwald/build-task-in-solution-demo, UsingTask docs
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.