Skip to content

[Xamarin.Android.Build.Tasks] Remove RunWithLogging - #13614

Merged
jonathanpeppers merged 3 commits into
mainfrom
simonrozsival-remove-runwithlogging-target
Nov 18, 2026
Merged

jonathanpeppers merged 3 commits into
mainfrom
simonrozsival-remove-runwithlogging-target

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

RunWithLogging duplicated application launch and log collection in a separate MSBuild target. It installed and restarted the app, enabled runtime logging with debug.dotnet.log, resized and cleared the device-wide logcat buffer, waited one second, and wrote a device-wide snapshot to obj/.../logcat.txt. Clearing the buffer discards other processes' logs and the fixed delay limits the captured window.

The unified runner from #12906 already builds, deploys and launches the app. dotnet run restarts it and streams PID-filtered logcat until exit or Ctrl+C; dotnet build -t:Run uses the same runner for a non-waiting launch. Runtime logging can be enabled using the existing Android system property, and device-wide logs can still be collected directly with adb logcat. Keeping a second target solely to combine these operations is no longer necessary.

This removes RunWithLogging, _PrepareRunWithLogging, their properties and the obsolete test. It also removes XASleepInternal from the shipped task assembly and targets. The task itself remains in the internal prep tasks: emulator shutdown and SDK-image installation retries still use it.

Compatibility and migration

This is a breaking change for scripts invoking -t:RunWithLogging or setting RunLogVerbose or RunLogDelayInMS; the old target now reports MSB4057. The replacement is not an exact behavioral match: it does not automatically set debug.dotnet.log, resize or clear logcat, wait for a fixed interval, or create a device-wide snapshot. It also does not add a new runtime-logging MSBuild property.

For equivalent runtime categories and streaming application logs, run from the app project directory:

adb shell setprop debug.dotnet.log default,assembly,timing
dotnet run -p:_AndroidRunLogcatArgs=DOTNET-assembly:V

The explicit filter matters: the runner defaults to DOTNET-assembly:S, which suppresses assembly-tag output even when the assembly category is enabled. Use all instead of the category list for the old RunLogVerbose=true behavior. adb logcat > logcat.txt captures a continuous device-wide log, or adb logcat -d > logcat.txt captures the current buffer. Clear or resize that buffer separately if needed. The system property persists until cleared:

adb shell setprop debug.dotnet.log "''"

The updated development tips document these steps. The DOTNET-assembly tag reflects the runtime tag rename in #13532.

Validation

  • make prepare && make leeroy — passed; builds the SDK, extra API levels and local workload.
  • ./dotnet-local.sh test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter 'Name~BuildOrderTests' — passed, 6/6.
  • ./dotnet-local.sh build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj -t:RunWithLogging -v:q — failed as expected with MSB4057.
  • ./dotnet-local.sh build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj -t:Run '-p:AdbTarget=-s emulator-5560' -v:q — passed and launched the sample on an isolated API 35 emulator.
  • After setting debug.dotnet.log, ./dotnet-local.sh run --project samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj --device emulator-5560 launched and streamed with zero DOTNET-assembly lines; repeating with -p:_AndroidRunLogcatArgs=DOTNET-assembly:V emitted 208 assembly lines. Both runs exited successfully after stopping the app.
  • Confirmed the built shipped task assembly no longer contains XASleepInternal; the internal emulator-task call sites remain.

simonrozsival and others added 3 commits November 13, 2026 14:11
`dotnet run` (and `-t:Run`) now launches the app and streams
PID-filtered logcat until exit, which covers the use case of
`RunWithLogging`. Remove the `RunWithLogging` and
`_PrepareRunWithLogging` targets, their properties, and the now-unused
shipped `XASleepInternal` task registration.

Breaking change: the public `RunWithLogging` target and the
`RunLogVerbose` and `RunLogDelayInMS` properties are removed.

Documentation/workflow/DevelopmentTips.md now describes enabling
runtime logging via `adb shell setprop debug.dotnet.log ...` followed
by `dotnet run`. It also notes that `monodroid-assembly` output is
suppressed by default and can be shown with
`-p:_AndroidRunLogcatArgs=monodroid-assembly:V` or via plain
`adb logcat`.

Co-authored-by: Copilot App <[email protected]>
Use the DOTNET-assembly tag introduced in the current Android
runtime so the documented dotnet run filter enables assembly logs.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 12:02

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

No active review issues are reported for the legacy logging-target removal and related cleanup.

No open issues 🎉

What changed in this PR

Removes the legacy RunWithLogging target in favor of the unified Android runner, eliminating duplicate launch logic and device-wide logcat manipulation. Scripts using the removed target must migrate to dotnet run and explicit adb logging commands.

Changes:

  • Removes the logging targets, associated properties, and obsolete test.
  • Removes XASleepInternal from the shipped task assembly while preserving it for internal preparation workflows.
  • Documents runtime logging configuration, assembly-tag filtering, and device-wide capture.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Build.Tasks.csproj Stops compiling the internal sleep task into the shipped assembly.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildOrderTests.cs Removes the test for the deleted logging preparation target.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.Application.targets Removes logging targets, properties, and sleep-task registration.
Documentation/​workflow/​DevelopmentTips.md Replaces legacy instructions with dotnet run and manual logging guidance.
Documentation/​docs-mobile/​building-apps/​build-targets.md Removes the obsolete RunWithLogging reference section.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member

🤖 CI is red because the NativeAOT test ManagedPeerCycleSurvivesJavaRootAndIsCollectedAfterRelease failed. The same assertion has failed on unrelated PRs (tracked in #13429), and this PR does not change the GC bridge, so this looks unrelated to the change. Please retry the failed Package Tests → APKs 2 job; the build is not green until it passes.

@jonathanpeppers
jonathanpeppers merged commit 5ecb8f7 into main Nov 18, 2026
37 of 39 checks passed
@jonathanpeppers
jonathanpeppers deleted the simonrozsival-remove-runwithlogging-target branch November 18, 2026 18:06
simonrozsival added a commit that referenced this pull request Nov 21, 2026
The rebase onto cc7cbf6 kept the pre-rebase MSTest conversions of
files that main had changed since aa688ac, which reverted those
changes and broke the build. For each affected file, convert main's
old and new NUnit versions with the same converter and merge the
difference into the MSTest file:

  * cca255c (#13592): drop the Android lint tests and assertions.
  * 5b32fb1 (#13602): add RelativeDirectoriesUseProjectDirectory and
    the -mt CollectNonEmptyDirectories coverage.
  * 78ef747 (#13655): add OpenGenericProxiesKeepTheReflectionActivationConstructor.
  * 18b8940 (#13585): add the generator nullability/obsolete tests.
  * dcbd008 (#13580): add the AmbiguousFunctionMetadata_* tests.
  * 667e27a (#13621): add the sdkmanager package ID tests.
  * 5ecb8f7 (#13614): drop RunWithLoggingEnablesManagedTimingLogger.
  * 8287b17 (#13680), 4bfcc92 (#13681): restore the re-enabled
    tests and removed TODOs.
  * 5d81a0f (#13666): expect platform-tools 37.0.3.
  * 8442c75 (#13601): assert the pulled device TRX is deleted.

Also drop the EnableNUnitRunner/OutputType lines that 857f463
(#13563) added to Xamarin.Android.Build.Tests and MSBuildDeviceIntegration;
MSTestReferences.projitems sets both.

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants