Skip to content

Instantly share code, notes, and snippets.

@rmarinho
Created February 12, 2026 17:35
Show Gist options
  • Select an option

  • Save rmarinho/8a7ae548e0928eb13adecc013955377f to your computer and use it in GitHub Desktop.

Select an option

Save rmarinho/8a7ae548e0928eb13adecc013955377f to your computer and use it in GitHub Desktop.
Dependencies

Yes! The Android workload does expose default dependency versions directly in its .props files. Here are the alternative ways to get Android SDK dependencies:


1. Read MSBuild Props Files Directly (No project needed)

The workload ships default versions in:

  • /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/<version>/tools/Xamarin.Android.Common.props
  • /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/<version>/tools/Xamarin.Installer.Common.props

These contain:

<AndroidSdkBuildToolsVersion>36.0.0</AndroidSdkBuildToolsVersion>
<AndroidSdkPlatformToolsVersion>36.0.0</AndroidSdkPlatformToolsVersion>
<AndroidSdkPlatformVersion>android-36</AndroidSdkPlatformVersion>
<AndroidCommandLineToolsVersion>19.0</AndroidCommandLineToolsVersion>
<JavaSdkVersion>21.0.8</JavaSdkVersion>
<AndroidNdkVersion>26.3.11579264</AndroidNdkVersion>

Advantage: No need to run dotnet build against a project — just parse the props file from the installed workload pack.


2. Use dotnet msbuild -getProperty (Lightweight query)

dotnet msbuild YourProject.csproj -getProperty:AndroidSdkBuildToolsVersion -getProperty:AndroidSdkPlatformVersion -getProperty:JavaSdkVersion

This is faster than running a full build target.


3. Query the CalculateProjectDependencies Task Directly

The Xamarin.Android.Build.Tasks.dll contains a CalculateProjectDependencies MSBuild task that computes dependencies based on inputs like AndroidApiLevel, BuildToolsVersion, etc. You could invoke this programmatically if you're already using MSBuild APIs.


Summary

Method Needs Project? Speed Gets Project-Specific Overrides?
Parse .props files Fastest ❌ (defaults only)
dotnet msbuild -getProperty Fast
dotnet build -t:GetAndroidDependencies Slow

For the extension, parsing the workload's .props files would give you the baseline defaults (API 36, build-tools 36.0.0, etc.) without any MSBuild invocation. You'd only need project-specific queries if the user overrides SupportedOSPlatformVersion or AndroidSdkBuildToolsVersion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment