Skip to content

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

Closed
@jonathanpeppers

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

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