Skip to content

[dotnet test] APK not installed to device automatically #11154

@jonathanpeppers

Description

@jonathanpeppers

Summary

dotnet test with MTP mode does not install the APK to the device before running instrumentation. This means users must manually run dotnet build -t:Install before dotnet test --no-build, which is a poor experience.

Background

dotnet run works correctly because it goes through the MSBuild Run target, which depends on Install:

<_RunDependsOn>
  Install;
  _Run;
</_RunDependsOn>

But dotnet test with MTP evaluates RunCommand/RunArguments and launches the process directly — it never triggers the Run target, so Install never runs.

Current Workaround

In #11130, the test explicitly calls dotnet build -t:Install before dotnet test. But end users shouldn't need to do this.

Proposed Fix

Ensure the APK is installed automatically when dotnet test is used. Some options:

  1. Hook into a dotnet test target — add a target that runs before ComputeRunArguments or GetRunCommand that triggers Install when EnableMSTestRunner=true
  2. Have Microsoft.Android.Run install the APK — when in dotnet-test mode, run adb install before am instrument
  3. Document the workaround — require dotnet build -t:Install before dotnet test --no-build (least ideal)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssues that need to be assigned.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions