diff --git a/Documentation/guides/building-apps/build-targets.md b/Documentation/guides/building-apps/build-targets.md index ebd2c96d5fa..fc6697ce83f 100644 --- a/Documentation/guides/building-apps/build-targets.md +++ b/Documentation/guides/building-apps/build-targets.md @@ -96,6 +96,18 @@ MSBuild property controls which [Visual Studio SDK Manager repository](~/android/get-started/installation/android-sdk.md?tabs=windows#repository-selection) is used for package name and package version detection, and URLs to download. +## RunWithLogging + +Runs the application with additional logging enabled. Helpful when reporting or investigating an issue with +either the application or the runtime. If successful, messages printed to the screen will show location +of the logcat file with the logged messages. + +Properties which affect how the target works: + + * `/p:RunLogVerbose=true` enables even more verbose logging from MonoVM + * `/p:RunLogDelayInMS=X` where `X` should be replaced with time in milliseconds to wait before writing the + log output to file. Defaults to `1000`. + ## SignAndroidPackage Creates and signs the Android package (`.apk`) file. diff --git a/Documentation/workflow/DevelopmentTips.md b/Documentation/workflow/DevelopmentTips.md index 68f96dc1ac0..1ea7c172781 100644 --- a/Documentation/workflow/DevelopmentTips.md +++ b/Documentation/workflow/DevelopmentTips.md @@ -452,7 +452,7 @@ A second (better) way is to add this MSBuild target to your Android ```xml - - + @@ -160,7 +160,7 @@ ContinueOnError="WarnAndContinue" Command="kill -HUP $(_EmuPid)" /> - @@ -375,7 +375,7 @@ ContinueOnError="true"> - @@ -386,7 +386,7 @@ Condition=" '$(_SdkManagerExitCode)' != '0' "> - diff --git a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Sleep.cs b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Sleep.cs index 93da4a74661..37c04e189fa 100644 --- a/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Sleep.cs +++ b/build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/Sleep.cs @@ -3,19 +3,21 @@ using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using Microsoft.Android.Build.Tasks; + +using TPLTask = System.Threading.Tasks.Task; namespace Xamarin.Android.BuildTools.PrepTasks { - public class Sleep : Task + public class XASleepInternal : AndroidAsyncTask { + public override string TaskPrefix => "XASI"; public int Milliseconds { get; set; } - public override bool Execute () + public override TPLTask RunTaskAsync () { Log.LogMessage (MessageImportance.Normal, $"Going to sleep for {Milliseconds}ms"); - Thread.Sleep (Milliseconds); - - return true; + return TPLTask.Delay (Milliseconds, CancellationToken); } } } diff --git a/build-tools/xa-prep-tasks/xa-prep-tasks.csproj b/build-tools/xa-prep-tasks/xa-prep-tasks.csproj index d9c6ac53885..4cb84d00174 100644 --- a/build-tools/xa-prep-tasks/xa-prep-tasks.csproj +++ b/build-tools/xa-prep-tasks/xa-prep-tasks.csproj @@ -9,4 +9,8 @@ + + + + diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets index 96dfb705f95..4e03d35f525 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets @@ -7,6 +7,8 @@ This file contains targets specific for Android application projects. *********************************************************************************************** --> + + false @@ -28,4 +30,42 @@ This file contains targets specific for Android application projects. + + <_RunWithLoggingDependsOn> + Install; + + + <_RunLogFilePath Condition=" '$(_RunLogFilePath)' == '' ">$(IntermediateOutputPath)logcat.txt + false + + + + + + + + + <_MonoLog>default,assembly,timing=bare + <_MonoLog Condition=" '$(RunLogVerbose)' != 'false' ">$(_MonoLog),mono_log_level=debug,mono_log_mask=all + 1000 + + + + + + + + + + + + + + + + + diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj index 3003ed96c68..c80b4722758 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj @@ -312,6 +312,9 @@ Mono.Android\NativeLibraryReferenceAttribute.cs + + Xamarin.Android.BuildTools.PrepTasks\Sleep.cs + <_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.LaunchMode.cs" /> <_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ScreenOrientation.cs" /> <_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ConfigChanges.cs" />