Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ if (!UncompressedFileExtensions.IsNullOrWhiteSpace ()) {
## Formatting

C# code uses tabs (not spaces) and Mono style (`.editorconfig`):
- **NEVER** use `!` (null-forgiving operator) in C# code. Always refactor to avoid it, e.g. by having helper methods return non-null types or by checking for null explicitly.
- Preserve existing formatting and comments
- Space before `(` and `[`: `Foo ()`, `array [0]`
- Use `""` not `string.Empty`, `[]` not `Array.Empty<T>()`
- Minimal diffs - don't leave random empty lines
- Do NOT use `#region` or `#endregion`

```csharp
Foo ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This file contains targets specific for Android application projects.
<UsingTask TaskName="Xamarin.Android.Tasks.AndroidAdb" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.GetAndroidActivityName" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.GetAvailableAndroidDevices" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.BootAndroidEmulator" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.BuildTools.PrepTasks.XASleepInternal" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />

<PropertyGroup>
Expand Down Expand Up @@ -44,11 +45,47 @@ This file contains targets specific for Android application projects.
Returns="@(Devices)">
<GetAvailableAndroidDevices
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)">
ToolPath="$(AdbToolPath)"
EmulatorToolExe="$(EmulatorToolExe)"
EmulatorToolPath="$(EmulatorToolPath)">
<Output TaskParameter="Devices" ItemName="Devices" />
</GetAvailableAndroidDevices>
</Target>

<!--
***********************************************************************************************
_EnsureDeviceBooted

Target that ensures the selected device is online and ready. If $(Device) refers to an
unbooted AVD, this target boots the emulator and updates $(AdbTarget) to the resolved
ADB serial (e.g. "-s emulator-5554").
Runs before _GetPrimaryCpuAbi (in commercial builds) so $(AdbTarget) is correct,
and before _DeployApk/_DeployAppBundle (which use AdbTarget for adb commands)
when $(Device) is set.

Note: this target CANNOT use DependsOnTargets="_ResolveMonoAndroidSdks" because in commercial
builds _GetPrimaryCpuAbi is in $(_ResolveMonoAndroidSdksDependsOn), which would create a cycle:
_ResolveMonoAndroidSdks -> _GetPrimaryCpuAbi -> _EnsureDeviceBooted -> _ResolveMonoAndroidSdks
Instead, the task computes tool paths from $(AndroidSdkDirectory), which is available because
_ResolveSdks runs earlier in the dependency chain.
***********************************************************************************************
-->
<Target Name="_EnsureDeviceBooted"
BeforeTargets="_GetPrimaryCpuAbi;_DeployApk;_DeployAppBundle"
Condition=" '$(Device)' != '' ">
<BootAndroidEmulator
Device="$(Device)"
AndroidSdkDirectory="$(AndroidSdkDirectory)"
EmulatorToolExe="$(EmulatorToolExe)"
EmulatorToolPath="$(EmulatorToolPath)"
AdbToolExe="$(AdbToolExe)"
AdbToolPath="$(AdbToolPath)"
BootTimeoutSeconds="$(BootTimeoutSeconds)"
EmulatorExtraArguments="$(EmulatorExtraArguments)">
<Output TaskParameter="AdbTarget" PropertyName="AdbTarget" />
</BootAndroidEmulator>
</Target>

<Target Name="_AndroidComputeRunArguments"
BeforeTargets="ComputeRunArguments"
DependsOnTargets="$(_AndroidComputeRunArgumentsDependsOn)">
Expand Down
58 changes: 47 additions & 11 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,22 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
<value>Command '{0}' failed.\n{1}</value>
<comment>'{0}' is a failed command name (potentially with path) followed by all the arguments passed to it. {1} is the combined output on the standard error and standard output streams.</comment>
</data>
<data name="XA0143" xml:space="preserve">
<value>Failed to launch the Android emulator for AVD '{0}': {1}</value>
<comment>{0} - The AVD name.
{1} - The exception message.</comment>
</data>
<data name="XA0144" xml:space="preserve">
<value>The Android emulator for AVD '{0}' exited unexpectedly with exit code {1} before becoming available.</value>
<comment>{0} - The AVD name.
{1} - The process exit code.</comment>
</data>
<data name="XA0145" xml:space="preserve">
<value>The Android emulator for AVD '{0}' did not finish booting within {1} seconds. Increase 'BootTimeoutSeconds' or check the emulator configuration.</value>
<comment>The following is a literal name and should not be translated: BootTimeoutSeconds
{0} - The AVD name.
{1} - The timeout in seconds.</comment>
</data>
<data name="XAGRDL1000" xml:space="preserve">
<value>Executable 'gradlew' not found in project directory '{0}'. Please ensure the path to your Gradle project folder is correct, and that it contains Gradle Wrapper scripts.</value>
<comment>The following are literal names and should not be translated: gradlew, Gradle, Gradle Wrapper
Expand Down
Loading