Repository navigation
[Xamarin.Android.Build.Tasks] Remove RunWithLogging - #13614
Conversation
`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]>
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]>
There was a problem hiding this comment.
🟢 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
XASleepInternalfrom 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
|
🤖 CI is red because the NativeAOT test |
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]>
RunWithLoggingduplicated application launch and log collection in a separate MSBuild target. It installed and restarted the app, enabled runtime logging withdebug.dotnet.log, resized and cleared the device-wide logcat buffer, waited one second, and wrote a device-wide snapshot toobj/.../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 runrestarts it and streams PID-filtered logcat until exit or Ctrl+C;dotnet build -t:Runuses 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 withadb 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 removesXASleepInternalfrom 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:RunWithLoggingor settingRunLogVerboseorRunLogDelayInMS; the old target now reports MSB4057. The replacement is not an exact behavioral match: it does not automatically setdebug.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:
The explicit filter matters: the runner defaults to
DOTNET-assembly:S, which suppresses assembly-tag output even when theassemblycategory is enabled. Useallinstead of the category list for the oldRunLogVerbose=truebehavior.adb logcat > logcat.txtcaptures a continuous device-wide log, oradb logcat -d > logcat.txtcaptures 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-assemblytag 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.debug.dotnet.log,./dotnet-local.sh run --project samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj --device emulator-5560launched and streamed with zeroDOTNET-assemblylines; repeating with-p:_AndroidRunLogcatArgs=DOTNET-assembly:Vemitted 208 assembly lines. Both runs exited successfully after stopping the app.XASleepInternal; the internal emulator-task call sites remain.