Skip to content

Improve "first run" build & run time inside VS #8662

Description

@jonathanpeppers

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

.NET 7,8,9

Description

When you build an Android project, we have logic that "finds" the property $(RuntimeIdentifier) for the attached device:

https://github.com/xamarin/monodroid/blob/867ef5e9ead84e407419e6a1f5d64a3d6583f6d5/tools/msbuild/Xamarin.Android.Common.Debugging.targets#L451-L475

If you have no device attached, it just builds all 4 $(RuntimeIdentifiers).

Problem

This can slow down the 1st time experience for MAUI on Android, as there would be no emulators running or Android devices attached. This builds 4 architectures for no reason.

Solution 1

The IDE passes $(RuntimeIdentifier) to builds. This could be problematic as right now project defaults are:

<RuntimeIdentifier></RuntimeIdentifier>
<RuntimeIdentifiers>android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
<AppendRuntimeIdentifierToOutputPath>true</AppendRuntimeIdentifierToOutputPath>
<AppendRuntimeIdentifierToIntermediateOutputPath>true</AppendRuntimeIdentifierToIntermediateOutputPath>

This could have unforseen consequences, in trying to use RID for this. There are many general issues about RIDs in multi-targeted projects:

Solution 2

Invent a new property that would skip the <GetPrimaryCpu/> task and just set appropriate properties instead.

Steps to Reproduce

  1. File > New MAUI project
  2. Run in VS without an emulator running or device attached

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. added this to the .NET 9 milestone on Jan 22, 2024
  2. changed the title [-]Improve "first run" build & run time[/-] [+]Improve "first run" build & run time inside VS[/+] on Jan 22, 2024
  3. jonathanpeppers commented on Aug 15, 2024

    @jonathanpeppers
    MemberAuthor
  4. jonathanpeppers commented on Aug 15, 2024

    @jonathanpeppers
    MemberAuthor

    The current proposal is:

    • The IDE sets a new value -p:AdbTargetArchitecture
    • At this time, the emulator is closed, adb devices doesn't report anything
    • The IDE doesn't have the value for -p:AdbTarget at this time either

    So, the build could:

    • Skip _GetPrimaryCpuAbi if $(AdbTargetArchitecture) is set
    • Set appropriate values for $(RuntimeIdentifiers), etc.

    By the time the IDE Deploys, or runs the Install target:

    • Build is complete
    • Emulator is running
    • Install will be passed -p:AdbTarget as before, and passed -p:AdbTargetArchitecture for completeness (this way _GetPrimaryCpu is skipped).
  5. jonathanpeppers commented on Aug 15, 2024

    @jonathanpeppers
    MemberAuthor
  6. dellis1972 commented on Aug 16, 2024

    @dellis1972
    Contributor

    If the IDE knows what emulator it is going to launch before we do the build then this might work 👍

  7. locked and limited conversation to collaborators on Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.enhancementProposed change to current functionality.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions