Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AndroidToolTask] Log tool output as error #8861

Merged
merged 7 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion external/xamarin-android-tools
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file contains targets specific for Android application projects.
***********************************************************************************************
-->
<Project>
<UsingTask TaskName="Xamarin.Android.Tasks.AndroidAdb" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.GetAndroidActivityName" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.BuildTools.PrepTasks.XASleepInternal" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />

Expand Down Expand Up @@ -55,17 +56,53 @@ This file contains targets specific for Android application projects.

<Message Text="Preparing application to log more information" Importance="High" />
<Message Text="Setting the debug.mono.log property to: $(_MonoLog)" Importance="High" />
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell setprop debug.mono.log $(_MonoLog)" />
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) logcat -G 16M" />
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) logcat -c" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="shell"
Arguments="debug.mono.log $(_MonoLog)"
pjcollins marked this conversation as resolved.
Show resolved Hide resolved
/>
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="logcat"
Arguments="-G 16M"
/>
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="logcat"
Arguments="-c"
/>

<Message Text="Running the application and waiting for it to fully start" Importance="High" />
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell am start -S -W -n &quot;$(_AndroidPackage)/$(AndroidLaunchActivity)&quot;" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="shell"
Arguments="-S -W -n &quot;$(_AndroidPackage)/$(AndroidLaunchActivity)&quot;"
pjcollins marked this conversation as resolved.
Show resolved Hide resolved
/>

<Message Text="Sleeping for $(RunLogDelayInMS)ms to give logcat a chance to log all the messages" Importance="High" />
<XASleepInternal Milliseconds="$(RunLogDelayInMS)" />

<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) logcat -d > &quot;$(_RunLogFilePath)&quot;" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="logcat"
Arguments="-d"
>
<Output TaskParameter="Result" PropertyName="_LogcatOutput" />
</AndroidAdb>
<WriteLinesToFile
File="$(_RunLogFilePath)"
Lines="$(_LogcatOutput)"
/>
pjcollins marked this conversation as resolved.
Show resolved Hide resolved
<Message Text="Logcat output is available in $(_RunLogFilePath)" Importance="High" />
</Target>
</Project>
3 changes: 2 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/AndroidZipAlign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ protected override void LogEventsFromTextOutput (string singleLine, MessageImpor
{
if (ExitCode != 0)
Log.LogCodedError (DefaultErrorCode, singleLine);
base.LogEventsFromTextOutput (singleLine, messageImportance);
else
base.LogEventsFromTextOutput (singleLine, messageImportance);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Copyright (C) 2019 Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Xamarin.Android.Tasks.AndroidAdb" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Android.Tasks.GetAndroidActivityName" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
<Target Name="StartAndroidActivity"
DependsOnTargets="_ResolveMonoAndroidSdks;_GetAndroidPackageName">
Expand All @@ -19,11 +20,23 @@ Copyright (C) 2019 Microsoft Corporation. All rights reserved.
ManifestFile="$(IntermediateOutputPath)android\AndroidManifest.xml">
<Output TaskParameter="ActivityName" PropertyName="AndroidLaunchActivity" />
</GetAndroidActivityName>
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell am start -S -n &quot;$(_AndroidPackage)/$(AndroidLaunchActivity)&quot;" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="shell"
Arguments="am start -S -n &quot;$(_AndroidPackage)/$(AndroidLaunchActivity)&quot;"
/>
</Target>
<Target Name="StopAndroidPackage"
DependsOnTargets="_ResolveMonoAndroidSdks;_GetAndroidPackageName">
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell am force-stop &quot;$(_AndroidPackage)&quot;" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="shell"
Arguments="am force-stop &quot;$(_AndroidPackage)&quot;"
/>
</Target>
<PropertyGroup>
<AndroidAotCustomProfilePath Condition=" '$(AndroidAotCustomProfilePath)' == '' ">custom.aprof</AndroidAotCustomProfilePath>
Expand All @@ -42,14 +55,26 @@ Copyright (C) 2019 Microsoft Corporation. All rights reserved.
</PropertyGroup>
</Target>
<Target Name="_SetAotProfilingPropsOnDevice">
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) shell setprop debug.mono.profile aot:port=$(AndroidAotProfilerPort)" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="shell"
Arguments="setprop debug.mono.profile aot:port=$(AndroidAotProfilerPort)"
/>
</Target>
<Target Name="BuildAndStartAotProfiling"
DependsOnTargets="$(_BeginAotProfilingDependsOnTargets)">
</Target>
<Target Name="FinishAotProfiling"
DependsOnTargets="_ResolveSdks;_ResolveMonoAndroidSdks">
<Exec Command="&quot;$(AdbToolPath)adb&quot; $(AdbTarget) forward tcp:$(AndroidAotProfilerPort) tcp:$(AndroidAotProfilerPort)" />
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="forward"
Arguments="tcp:$(AndroidAotProfilerPort) tcp:$(AndroidAotProfilerPort)"
/>
<Exec Command="&quot;$(AProfUtilToolPath)aprofutil&quot; $(AProfUtilExtraOptions) -s -v -p $(AndroidAotProfilerPort) -o &quot;$(AndroidAotCustomProfilePath)&quot;" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2583,9 +2583,6 @@ because xbuild doesn't support framework reference assemblies.

<Target Name="_DeployApk"
Condition=" '$(AndroidPackageFormat)' != 'aab' ">
<PropertyGroup>
<_DeployCommand>&quot;$(AdbToolPath)adb&quot; $(AdbTarget) install -r &quot;$(ApkFileSigned)&quot;</_DeployCommand>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this being removed? Its not mentioned in the PR description?

I thought this and the _UnintallCommand were used by dotnet under the hood.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see these _DeployCommand or _UninstallCommand command properties being used anywhere here or in monodroid. It looked like they were left overs from when the AndroidAdb task was introduced, and they could be safely removed?

</PropertyGroup>
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
Expand Down Expand Up @@ -2620,9 +2617,6 @@ because xbuild doesn't support framework reference assemblies.
<Target Name="_DeployAppBundle"
Condition=" '$(AndroidPackageFormat)' == 'aab' "
DependsOnTargets="_BuildApkSet">
<PropertyGroup>
<_UninstallCommand>&quot;$(AdbToolPath)adb&quot; $(AdbTarget) uninstall -k &quot;$(_AndroidPackage)&quot;</_UninstallCommand>
</PropertyGroup>
<AndroidAdb
Condition=" '$(EmbedAssembliesIntoApk)' == 'true' "
ContinueOnError="True"
Expand Down
Loading