Skip to content

Add TaskFactory="TaskHostFactory" Runtime="NET" to xa-prep-tasks and BootstrapTasks UsingTask elements - #10893

Merged
jonathanpeppers merged 2 commits into
mainfrom
copilot/fix-windows-file-locking-issues
Mar 6, 2026
Merged

Add TaskFactory="TaskHostFactory" Runtime="NET" to xa-prep-tasks and BootstrapTasks UsingTask elements#10893
jonathanpeppers merged 2 commits into
mainfrom
copilot/fix-windows-file-locking-issues

Conversation

Copilot AI commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Windows file locking on task assembly DLLs causes build failures when MSBuild loads xa-prep-tasks and BootstrapTasks in-process. Running them out-of-process via TaskHostFactory avoids the lock, and Runtime="NET" ensures they run on .NET even under MSBuild.exe (.NET Framework) in Visual Studio.

Changes

  • Added TaskFactory="TaskHostFactory" Runtime="NET" to all 42 <UsingTask/> elements referencing $(PrepTasksAssembly) or $(BootstrapTasksAssembly) across 16 files
  • Not applied to shipped product <UsingTask/> elements (Xamarin.Android.Common.targets, Microsoft.Android.Sdk/*.targets, etc.) — these would affect customer builds
  • Updated .github/copilot-instructions.md with guidance for future task additions

Example

Before:

<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.Adb" />

After:

<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.Adb" TaskFactory="TaskHostFactory" Runtime="NET" />

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.

…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
jonathanpeppers marked this pull request as ready for review March 6, 2026 00:07
Copilot AI review requested due to automatic review settings March 6, 2026 00:07

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 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.md with 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)

@jonathanpeppers
jonathanpeppers merged commit d57538a into main Mar 6, 2026
9 of 10 checks passed
@jonathanpeppers
jonathanpeppers deleted the copilot/fix-windows-file-locking-issues branch March 6, 2026 14:21
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants