Skip to content

[Xamarin.Android.Build.Tasks] Remove redundant output logging - #13129

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-task-output-logging
Oct 13, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-task-output-logging

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Reduce unnecessary logging work in Android MSBuild tasks, particularly with multi-threaded MSBuild. Formatting output values and item lists creates extra allocations and log messages. For out-of-process task hosts, those messages also need to be serialized and routed back to MSBuild. Bound task outputs already have structural records in the binlog, so repeating their values as task-authored messages is redundant.

For example, <ValidateJavaVersion/> logs an output heading plus JdkVersion and MinimumRequiredJdkVersion, even though its existing output bindings record $(_JdkVersion) and $(_DefaultJdkVersion). Removing these dumps avoids three extra messages per invocation without changing the outputs or how often the task runs.

Audit all 178 repository-owned task classes, including inherited and partial definitions, src, build-tools, in-tree Java.Interop and inline tasks. Remove output-only scalar/item/metadata dumps and headings from 29 task files, and update assertions in six existing test files. Keep output properties, computations and bindings unchanged, together with input diagnostics, warnings/errors, decisions, progress, useful counts, file-operation outcomes and protected virtual hooks. Java.Interop has no output-only dump requiring an edit. This does not change nested-build scheduling or gate common logging helpers globally.

Representative normal and strict multi-threaded (-mt) Android rebuilds show 105 matched dump headers/scalars dropping to zero. The affected tasks retain 57 bound properties, two nonempty items and 17 metadata entries in their structural output records. In particular, $(_JdkVersion)=21.0.8 and $(_DefaultJdkVersion)=11.0 remain recorded. The two intentionally random temporary-directory roots are normalized for comparison; their output property names and derived paths are preserved.

This is a performance-motivated reduction in redundant message traffic, not a claim of a measured end-to-end build-time speedup.

Output visibility caveats

Removing a dump does not make an unbound output structurally visible. No new product bindings are added. The following removed dumps have no in-tree <Output/> binding:

  • <Git/>: Output; <Which/>: Location; <GetFilesThatExist/>: FilesThatExist.
  • <GetImportedLibraries/>: Jars, NativeLibraries, ManifestDocuments.
  • Legacy <ResolveAndroidTooling/>: TargetFrameworkVersion; <ReadLibraryProjectImportsCache/>: Jars.
  • <RemoveDirFixed/> and <RemoveUnknownFiles/>: RemovedDirectories.
  • <ResolveLibraryProjectImports/>: Jars, ResolvedAssetDirectories, ResolvedResourceDirectories, ResolvedEnvironmentFiles, ResolvedResourceDirectoryStamps, ProguardConfigFiles, ExtractedDirectories.

Cache-producing tasks still write their existing cache files; existing bound cache-reader outputs provide later structural records where applicable. There is no claim that every unbound value is captured.

Local validation and exact commands

Built the changed SDK in this worktree using the pinned local SDK 12.0.100-alpha.1.26509.101, MSBuild 18.13.0-1.26509.101 and Android Debug workload 37.99.0. No installed Android RC1 workload was used.

Commands below run from the repository root in cmd.exe, with:

set DOTNET_CLI_USE_MSBUILD_SERVER=0
set MSBUILDDISABLENODEREUSE=1
set DOTNET_CLI_TELEMETRY_OPTOUT=1
set "A=C:\Users\jopepper\.copilot\session-state\c7241405-6476-473c-aa61-b0d31cde7880\files"

Full local SDK build: passed, zero errors, 92 existing warnings.

call "C:\Program Files\Microsoft Visual Studio\18\Canary\Common7\Tools\VsDevCmd.bat" >nul && call ".\dotnet-local.cmd" build Microsoft.Android.slnx -t:BuildDotNet -nr:false -v:minimal -bl:%A%\verified-sdk-build.binlog

Test project rebuild after removing OutputLoggingTests.cs: passed, zero warnings/errors. The separate fixture is not part of this PR.

call ".\dotnet-local.cmd" build .\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -p:BuildProjectReferences=false -nr:false -v:minimal -bl:%A%\remove-output-logging-tests-build.binlog

Host task regressions and sequential/parallel CoreCLR layout integration: 67 passed, zero failed/skipped.

call ".\dotnet-local.cmd" test .\bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~ValidateJavaVersionTests|FullyQualifiedName~ResolveSdksTaskTests|FullyQualifiedName~CopyIfChangedTests|FullyQualifiedName~RemoveDirTests|Name~GetPrimaryCpuAbiHonorsAdbTargetArchitecture|Name~SelectRuntimeIdentifier|Name~GetSupportedAbis|Name~DeviceCache|(FullyQualifiedName~CodeBehindTests&Name~CoreCLR&(Name~SuccessfulBuildFew|Name~SuccessfulBuildMany)&Name!~DTB)" --logger "trx;LogFileName=pr-host.trx" --results-directory %A%\TestResults

Modern package-name output/error validation: 4 passed, zero failed/skipped.

call ".\dotnet-local.cmd" test .\bin\TestDebug\net11.0\Microsoft.Android.Build.Tasks.Tests.dll --filter "FullyQualifiedName~GetAndroidPackageNameTests" --logger "trx;LogFileName=pr-modern-package.trx" --results-directory %A%\TestResults

Session-only preparation-task output checks: passed all six changed tasks, including item metadata.

call ".\dotnet-local.cmd" msbuild %A%\PrepTaskOutputProbe.proj -nr:false -v:minimal -bl:%A%\pr-prep-output-probe.binlog

Read-only Pixel 10 checks: passed live, cached and architecture-shortcut <GetPrimaryCpuAbi/> paths, matching adb getprop results (arm64-v8a, android-arm64, API 36). Explicit serial 58230DLCR0013R; no app installed or changed.

call ".\dotnet-local.cmd" msbuild %A%\DeviceTaskOutputProbe.proj -p:ExpectedAbi=arm64-v8a -p:ExpectedSdk=36 -nr:false -v:minimal -bl:%A%\device-output-probe.binlog

Representative Android builds: passed normal and strict multi-threaded builds, zero warnings/errors. Binlog inspection confirms strict mode was enabled for -mt.

call ".\dotnet-local.cmd" build %A%\TaskOutputProbe\TaskOutputProbe.csproj -t:Rebuild -c Debug -m -nr:false -v:minimal -bl:%A%\changed-app.binlog
call ".\dotnet-local.cmd" build %A%\TaskOutputProbe\TaskOutputProbe.csproj -t:Rebuild -c Debug --no-restore -m -mt -nr:false -v:minimal -bl:%A%\changed-app-mt.binlog

binlogtool inspection and output comparisons: passed, removed dump text absent and affected bound outputs preserved.

binlogtool search %A%\changed-app-mt.binlog JdkVersion
binlogtool listtools %A%\changed-app.binlog
python %A%\compare-binlogs.py
python %A%\compare-binlogs.py changed-app-mt

Saved local evidence includes baseline-app.binlog, changed-app.binlog, changed-app-mt.binlog, audit-inventory.json, binlog-comparison.json and changed-app-mt-comparison.json. The comparisons are scoped to changed tasks: untouched typemap item ordering varies, and the later untouched assembly-processing output includes an additional local-pack Mono.Android.Export.pdb.

No linked issue.


Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

Reduce the logging work performed by Android MSBuild tasks, especially
when using multi-threaded MSBuild.  Formatting output dumps produces
extra messages and allocations.  Out-of-process task hosts also need to
serialize and route those messages back to the build.

Bound task outputs already have structural binlog records.  Remove plain
scalar, item and metadata dumps and output-only headings across all
repository-owned task implementations.  Preserve output properties and
bindings, computations, meaningful diagnostics and protected virtual hooks.
Unbound outputs are not claimed to be structurally recorded.

Update assertions in existing tests without introducing a separate
OutputLoggingTests fixture.  Representative normal and strict
multi-threaded builds eliminate 105 dump headers/scalars while preserving
the affected bound outputs.  This reduces redundant logging work; it is
not a measured end-to-end performance speedup.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c7241405-6476-473c-aa61-b0d31cde7880
Copilot AI balanced review requested due to automatic review settings October 13, 2026 18:54

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.

🟢 Approval recommended

Task behavior and output bindings remain intact, with only optional test-specificity suggestions outstanding.

3 open findings
What changed in this PR

Removes redundant MSBuild task output dumps to reduce logging allocations and message traffic while preserving task outputs and bindings.

Changes:

  • Removes scalar, item, and metadata output logging from 29 tasks.
  • Preserves diagnostic, decision, warning, and error messages.
  • Updates tests to verify outputs remain populated without redundant logs.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ValidateJavaVersionTests.cs Verifies Java outputs without dumps.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ResolveSdksTaskTests.cs Checks SDK outputs and removed logging.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​RemoveDirTests.cs Verifies removed-directory output.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​CopyIfChangedTests.cs Verifies modified-file output.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​DebuggingTasksTests.cs Checks ABI outputs without dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ValidateJavaVersion.cs Removes JDK output logging.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ResolveSdksTask.cs Removes resolved SDK path dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ResolveLibraryProjectImports.cs Removes imported-item dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ResolveAndroidTooling.cs Removes tooling output dumps while retaining the virtual hook.
src/​Xamarin.Android.Build.Tasks/​Tasks/​RemoveUnknownFiles.cs Removes deleted-item output dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​RemoveDirFixed.cs Removes removed-directory dump.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ReadLibraryProjectImportsCache.cs Removes cached-item dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ReadImportedLibrariesCache.cs Removes imported-library dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​Legacy/​ResolveAndroidTooling.cs Removes legacy framework output logging.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GetImportedLibraries.cs Removes discovered-library dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GetFilesThatExist.cs Removes existing-file dump.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GetExtraPackages.cs Removes package output logging.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateLayoutBindings.cs Removes generated-file dump.
src/​Xamarin.Android.Build.Tasks/​Tasks/​FindLayoutsToBind.cs Removes layout output dump.
src/​Xamarin.Android.Build.Tasks/​Tasks/​DetermineJavaLibrariesToCompile.cs Removes Java library dumps.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CreateTemporaryDirectory.cs Removes temporary-path logging.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CopyIfChanged.cs Removes modified-file dump.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CopyGeneratedJavaResourceClasses.cs Removes generated resource-file logging.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ConvertCustomView.cs Removes output metadata logging.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ComputeHash.cs Removes hashed-item dump.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CalculateLayoutCodeBehind.cs Removes layout result dumps.
src/​Xamarin.Android.Build.Debugging.Tasks/​Tasks/​GetPrimaryCpuAbi.cs Removes device output dumps.
src/​Microsoft.Android.Build.Tasks/​Tests/​Microsoft.Android.Build.Tasks.Tests/​GetAndroidPackageNameTests.cs Verifies package output without logging.
src/​Microsoft.Android.Build.Tasks/​Tasks/​GetAndroidPackageName.cs Removes package-name dump.
build-tools/​xa-prep-tasks/​Xamarin.Android.BuildTools.PrepTasks/​Which.cs Removes resolved-location logging.
build-tools/​xa-prep-tasks/​Xamarin.Android.BuildTools.PrepTasks/​GitCommitsInRange.cs Removes commit-count logging.
build-tools/​xa-prep-tasks/​Xamarin.Android.BuildTools.PrepTasks/​GitCommitHash.cs Removes abbreviated-hash logging.
build-tools/​xa-prep-tasks/​Xamarin.Android.BuildTools.PrepTasks/​GitBranch.cs Removes branch output logging.
build-tools/​xa-prep-tasks/​Xamarin.Android.BuildTools.PrepTasks/​GitBlame.cs Removes commit metadata dumps.
build-tools/​xa-prep-tasks/​Xamarin.Android.BuildTools.PrepTasks/​Git.cs Removes duplicated command-output logging.

🧠 Review effort: Balanced

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 13, 2026
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) October 13, 2026 21:56
@jonathanpeppers
jonathanpeppers merged commit dc740e8 into main Oct 13, 2026
42 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-task-output-logging branch October 13, 2026 22:13
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/backport to release/11.0.1xx

@github-actions github-actions Bot unlocked this conversation Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@jonathanpeppers backporting to release/11.0.1xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick dc740e88cf17201a616cfec5ff718842f43c46b3

Auto-merging build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/GitCommitsInRange.cs
Auto-merging src/Xamarin.Android.Build.Debugging.Tasks/Tasks/GetPrimaryCpuAbi.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Debugging.Tasks/Tasks/GetPrimaryCpuAbi.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tasks/ResolveAndroidTooling.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Tasks/ResolveAndroidTooling.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tasks/ValidateJavaVersion.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DebuggingTasksTests.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DebuggingTasksTests.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ValidateJavaVersionTests.cs
error: could not apply dc740e88c... [Xamarin.Android.Build.Tasks] Remove redundant output logging (#13129)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: [Xamarin.Android.Build.Tasks] Remove redundant output logging
Using index info to reconstruct a base tree...
M	build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/GitCommitsInRange.cs
M	src/Xamarin.Android.Build.Debugging.Tasks/Tasks/GetPrimaryCpuAbi.cs
M	src/Xamarin.Android.Build.Tasks/Tasks/ResolveAndroidTooling.cs
M	src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
M	src/Xamarin.Android.Build.Tasks/Tasks/ValidateJavaVersion.cs
M	src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DebuggingTasksTests.cs
M	src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs
M	src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ValidateJavaVersionTests.cs
Falling back to patching base and 3-way merge...
Auto-merging build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/GitCommitsInRange.cs
Auto-merging src/Xamarin.Android.Build.Debugging.Tasks/Tasks/GetPrimaryCpuAbi.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Debugging.Tasks/Tasks/GetPrimaryCpuAbi.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tasks/ResolveAndroidTooling.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Tasks/ResolveAndroidTooling.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tasks/ValidateJavaVersion.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DebuggingTasksTests.cs
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DebuggingTasksTests.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ValidateJavaVersionTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 [Xamarin.Android.Build.Tasks] Remove redundant output logging
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants