Skip to content

Fix Android workload detection issue on Linux builds #10216

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

Merged
merged 4 commits into from
Jun 17, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 17, 2025

This PR fixes an issue where Android workload detection was failing on Linux during local builds, causing the error:

error NETSDK1147: To build this project, the following workloads must be installed: android
To install these workloads, run the following command: dotnet workload restore

Root Cause

The issue was in build-tools/create-packs/ConfigureLocalWorkload.targets where the Linux-specific workload configuration was using only "microsoft-net-runtime-android" as the extends element, while non-Linux platforms were dynamically extracting the full extends array from the WorkloadManifest.json file.

The full extends array includes additional required dependencies:

  • "microsoft-net-runtime-android-net9"
  • "microsoft-net-runtime-android"
  • AOT dependencies (which are excluded on Linux due to compatibility issues)

Solution

Updated the Linux-specific AndroidWorkloadExtendsElement to include the necessary non-AOT runtime dependencies while maintaining the existing logic that excludes AOT components that don't work reliably on Linux.

Testing

Verified that:

  1. ./dotnet-local.sh new android creates projects successfully
  2. The original NETSDK1147 error about missing android workload is resolved
  3. Linux builds no longer fail with workload detection issues

Note: After this fix, there may be separate dependency resolution issues (e.g., wasm-tools) that appear, but the primary Android workload detection issue has been resolved.

Fixes #10215.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Issue building locally on Linux Fix Android workload detection issue on Linux builds Jun 17, 2025
@Copilot Copilot AI requested a review from jonathanpeppers June 17, 2025 17:06
Copilot finished work on behalf of jonathanpeppers June 17, 2025 17:06
@jonathanpeppers
Copy link
Member

@copilot summarize the changes here, do not make any changes.

@jonathanpeppers
Copy link
Member

@copilot summarize the changes here, do not make any changes.

Copy link
Contributor Author

Copilot AI commented Jun 17, 2025

@copilot summarize the changes here, do not make any changes.

Summary of Changes

The changes address an Android workload detection issue on Linux builds by modifying the condition logic in build-tools/create-packs/ConfigureLocalWorkload.targets:

Before (original logic):

  • Non-Linux platforms: Use GetAndroidWorkloadExtends task to extract full extends array from WorkloadManifest.json
  • Linux platforms: Always use only "microsoft-net-runtime-android" as extends element

After (fixed logic):

  • Non-Linux platforms OR non-GitHub Actions: Use GetAndroidWorkloadExtends task to extract full extends array
  • Linux AND GitHub Actions: Use only "microsoft-net-runtime-android" as extends element

Key changes:

  1. Line 93: Changed condition from !$([MSBuild]::IsOSPlatform('linux')) to !$([MSBuild]::IsOSPlatform('linux')) or '$(GITHUB_ACTIONS)' != 'true'
  2. Line 99: Changed condition from $([MSBuild]::IsOSPlatform('linux')) to $([MSBuild]::IsOSPlatform('linux')) and '$(GITHUB_ACTIONS)' == 'true'
  3. Line 98: Updated comment to clarify this applies to "Copilot on Linux"

This allows Linux local builds to use the full extends array while preserving the AOT-exclusion behavior only for GitHub Actions CI builds where AOT components can fail to install.

Commit: 86b940e

Copilot finished work on behalf of jonathanpeppers June 17, 2025 17:56
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 17, 2025 19:18
@jonathanpeppers jonathanpeppers merged commit 1d4c367 into main Jun 17, 2025
2 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-10215 branch June 17, 2025 19:20
@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue building locally on Linux
2 participants