Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<MicrosoftAndroidSdkPackName Condition="$([MSBuild]::IsOSPlatform('windows'))">Microsoft.Android.Sdk.Windows</MicrosoftAndroidSdkPackName>
<MicrosoftAndroidSdkPackName Condition="$([MSBuild]::IsOSPlatform('linux'))">Microsoft.Android.Sdk.Linux</MicrosoftAndroidSdkPackName>
<MicrosoftAndroidSdkPackName Condition="$([MSBuild]::IsOSPlatform('osx'))">Microsoft.Android.Sdk.Darwin</MicrosoftAndroidSdkPackName>
<!-- The NuGet with the MSBuild targets, tasks, and native runtimes; see build-tools/create-packs/Microsoft.Android.Sdk.proj -->
<MicrosoftAndroidSdkPackageId>Microsoft.Android.$(DotNetTargetFramework)</MicrosoftAndroidSdkPackageId>
</PropertyGroup>
<PropertyGroup>
<MicrosoftAndroidPacksRootDir>$(BuildOutputDirectory)lib\packs\</MicrosoftAndroidPacksRootDir>
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
<Compile Include="$(MSBuildThisFileDirectory)src\utils\NullableAttributes.cs" Visible="false" />
</ItemGroup>

<!-- The android workload sets $(MicrosoftAndroidPackageVersion) for the current .NET version -->
<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and '$(MicrosoftAndroidPackageVersion)' != '' and '@(PackageReference->WithMetadataValue('Identity', 'Microsoft.Android'))' == '' ">
<PackageReference Include="Microsoft.Android" Version="$(MicrosoftAndroidPackageVersion)" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions Documentation/docs-mobile/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@
href: messages/xa1050.md
- name: XA1051
href: messages/xa1051.md
- name: XA1052
href: messages/xa1052.md
- name: "XA2xxx: Linker"
items:
- name: "XA2xxx: Linker"
Expand Down
1 change: 1 addition & 0 deletions Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla
+ [XA1049](xa1049.md): The 'AndroidEnableMarshalMethods' MSBuild property is no longer supported.
+ [XA1050](xa1050.md): The 'AndroidR8ObfuscationMode' MSBuild property has an invalid value.
+ [XA1051](xa1051.md): The AndroidStaticJniInitFunction MSBuild item is not supported with NativeAOT.
+ [XA1052](xa1052.md): The 'Microsoft.Android' NuGet package is required to build 'net12.0-android' projects.

## XA2xxx: Linker

Expand Down
35 changes: 35 additions & 0 deletions Documentation/docs-mobile/messages/xa1052.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: .NET for Android error XA1052
description: XA1052 error code
ms.date: 11/24/2026
f1_keywords:
- "XA1052"
---

# .NET for Android error XA1052

## Example messages

```dotnetcli
error XA1052: The 'Microsoft.Android' NuGet package is required to build 'net12.0-android' projects. Add <PackageReference Include="Microsoft.Android" Version="37.0.0" /> to the project file.
```

## Issue

Starting with .NET 12, the Android build is part of the `Microsoft.Android`
NuGet package. The `android` workload only installs this package for offline
restore; it does not add the package to projects.

## Solution

Add a `PackageReference` to the `Microsoft.Android` NuGet package, with the
version from the error message:

```xml
<ItemGroup>
<PackageReference Include="Microsoft.Android" Version="37.0.0" />
</ItemGroup>
```

The `$(MicrosoftAndroidPackageVersion)` MSBuild property contains the
version of the installed `android` workload.
7 changes: 3 additions & 4 deletions Documentation/workflow/HowToAddNewApiLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,13 @@ You should search-and-replace instances of your local directory name with `..\..
- Add level to `/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs`
to enable running ApiCompat against the new level. (ex: `{ "v11.0.99", "v11.0" }`)
- Add level to `DefaultTestSdkPlatforms` in `/build-tools/automation/yaml-templates/variables.yaml`
- Update `WorkloadManifest.in.json` with the `Microsoft.Android.Ref.*` and
`Microsoft.Android.Runtime.*.android` packs for the new API level.
- Update `DotNetInstallAndRunPreviewAPILevels` in `InstallAndRunTests.cs` to
retain the existing preview API levels and try to access a member added in
each one.
- Add the API level to `@(AndroidBuildApiLevel)` in `Configuration.props`.
This list drives binding builds, targeting-pack selection, pack creation,
local workload setup, and workload dependency installation:
This list drives binding builds, the `Microsoft.Android.net*.Ref.*` packages,
the `Microsoft.Android` dependency groups, the workload manifest, local
workload setup, and workload dependency installation:
```xml
<AndroidBuildApiLevel Include="36.1">
<PlatformId>CANARY</PlatformId>
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions build-tools/automation/azure-pipelines-internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ extends:
parameters:
buildResultArtifactName: Build Results - Linux
xaSourcePath: $(System.DefaultWorkingDirectory)/android
nugetArtifactName: $(LinuxNuGetArtifactName)
use1ESTemplate: true

# Package Tests Stage
Expand Down Expand Up @@ -375,12 +374,6 @@ extends:
artifactName: $(NuGetArtifactName)
downloadPath: $(Build.StagingDirectory)\unsigned\mac-win

- task: DownloadPipelineArtifact@2
displayName: Download unsigned Linux packages
inputs:
artifactName: $(LinuxNuGetArtifactName)
downloadPath: $(Build.StagingDirectory)\unsigned\linux

- task: UseDotNet@2
displayName: Install .NET 8 SDK for SwixBuild
inputs:
Expand Down
1 change: 0 additions & 1 deletion build-tools/automation/azure-pipelines-public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ stages:
parameters:
buildResultArtifactName: Build Results - Linux
xaSourcePath: $(System.DefaultWorkingDirectory)/android
nugetArtifactName: $(LinuxNuGetArtifactName)
use1ESTemplate: false

# Package Tests Stage
Expand Down
31 changes: 3 additions & 28 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,6 @@ extends:
handleUnmappedFiles: fail
timeoutInMinutes: 240

# Check - "Xamarin.Android (Prepare .NET Release Sign Linux Archive)"
- template: sign-artifacts/jobs/v4.yml@yaml-templates
parameters:
name: sign_net_linux
displayName: Sign Linux Archive
poolName: $(VSEngMicroBuildPool)
artifactName: $(LinuxNuGetArtifactName)
${{ if and(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.DefinitionName'], 'Xamarin.Android')) }}:
signType: Real
${{ else }}:
signType: Test
signedArtifactName: nuget-linux-signed
usePipelineArtifactTasks: true
uploadPrefix: sign-linux
handleUnmappedFiles: fail
timeoutInMinutes: 120

# Check - "Xamarin.Android (Prepare .NET Release Convert NuGet to MSI)"
- template: nuget-msi-convert/job/v5.yml@yaml-templates
parameters:
Expand All @@ -314,6 +297,7 @@ extends:
artifactName: nuget-signed
artifactPatterns: |
!*Darwin*
!*Linux*
propsArtifactName: $(NuGetArtifactName)
${{ if and(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.DefinitionName'], 'Xamarin.Android')) }}:
signType: Real
Expand All @@ -325,10 +309,7 @@ extends:
artifactName: nuget-signed
artifactPatterns: |
*Darwin*
downloadPath: $(Build.StagingDirectory)\drop\nugets
- task: DownloadPipelineArtifact@2
inputs:
artifactName: nuget-linux-signed
*Linux*
downloadPath: $(Build.StagingDirectory)\drop\nugets
postConvertSteps:
- task: DownloadPipelineArtifact@2
Expand All @@ -352,8 +333,7 @@ extends:
displayName: Publish symbols and Push to Maestro
dependsOn:
- nuget_convert
- sign_net_linux
condition: and(or(eq(dependencies.nuget_convert.result, 'Succeeded'), eq(dependencies.nuget_convert.result, 'SucceededWithIssues')), or(eq(dependencies.sign_net_linux.result, 'Succeeded'), eq(dependencies.sign_net_linux.result, 'SucceededWithIssues')))
condition: or(eq(dependencies.nuget_convert.result, 'Succeeded'), eq(dependencies.nuget_convert.result, 'SucceededWithIssues'))
timeoutInMinutes: 90
pool:
name: AzurePipelines-EO
Expand Down Expand Up @@ -385,11 +365,6 @@ extends:
artifactName: nuget-unsigned-symbols
downloadPath: $(Build.StagingDirectory)\symbols

- task: DownloadPipelineArtifact@2
inputs:
artifactName: nuget-linux-unsigned-symbols
downloadPath: $(Build.StagingDirectory)\symbols

- task: DownloadPipelineArtifact@2
inputs:
artifactName: DropMetadata-shipping-nugets
Expand Down
101 changes: 0 additions & 101 deletions build-tools/automation/yaml-templates/build-linux-steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,10 @@
parameters:
buildResultArtifactName: Build Results - Linux
xaSourcePath: $(System.DefaultWorkingDirectory)/android
nugetArtifactName: $(LinuxNuGetArtifactName)
makeMSBuildArgs: ''
use1ESTemplate: true

steps:
# Detect whether a previous attempt of this job already published the Linux SDK
# artifacts. Pipeline artifact names are immutable per build, so if an earlier
# attempt succeeded far enough to publish `nuget-linux-unsigned` (and/or its
# `-symbols` companion) but then failed in a later (often post-job) step, blindly
# rebuilding and republishing on a rerun always fails with "Artifact
# nuget-linux-unsigned already exists for build". We probe each artifact
# independently and set a per-artifact variable. When BOTH artifacts already
# exist we skip the ~20+ minute rebuild; each publish step is then skipped only
# for the artifact that already exists, so a partial prior publish (e.g. the SDK
# published but `-symbols` missing) still rebuilds and publishes just the missing
# artifact without colliding on the one that is already there. Any failure to
# query the API falls back to building normally (safe default).
- bash: |
set -eo pipefail
sdk_artifact='${{ parameters.nugetArtifactName }}'
symbols_artifact='${{ parameters.nugetArtifactName }}-symbols'
url="$(System.CollectionUri)$(System.TeamProject)/_apis/build/builds/$(Build.BuildId)/artifacts?api-version=7.1"
echo "Checking whether artifacts already exist for build $(Build.BuildId)..."
response="$(curl -sS -H "Authorization: Bearer $SYSTEM_ACCESSTOKEN" "$url" || true)"
normalized="$(echo "$response" | tr -d '[:space:]')"
check_artifact () {
name="$1"
var="$2"
if echo "$normalized" | grep -qF "\"name\":\"$name\""; then
echo "Found existing '$name'; a previous attempt already published it."
echo "##vso[task.setvariable variable=$var]true"
else
echo "No existing '$name' artifact."
echo "##vso[task.setvariable variable=$var]false"
fi
}
check_artifact "$sdk_artifact" AlreadyBuiltLinuxSdk
check_artifact "$symbols_artifact" AlreadyBuiltLinuxSdkSymbols
displayName: check for existing linux sdk artifacts
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- template: /build-tools/automation/yaml-templates/log-disk-space.yaml

- ${{ if ne(parameters.use1ESTemplate, true) }}:
Expand Down Expand Up @@ -83,75 +45,12 @@ steps:
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: make jenkins
retryCountOnTaskFailure: 1
condition: and(succeeded(), or(ne(variables['AlreadyBuiltLinuxSdk'], 'true'), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true')))

- template: /build-tools/automation/yaml-templates/generate-cgmanifest.yaml
parameters:
configuration: $(XA.Build.Configuration)
xaSourcePath: ${{ parameters.xaSourcePath }}

- script: make create-nupkgs CONFIGURATION=$(XA.Build.Configuration)
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: make create-nupkgs
condition: and(succeeded(), or(ne(variables['AlreadyBuiltLinuxSdk'], 'true'), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true')))

- template: /build-tools/automation/yaml-templates/log-disk-space.yaml

- task: CopyFiles@2
condition: and(succeeded(), or(ne(variables['AlreadyBuiltLinuxSdk'], 'true'), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true')))
inputs:
SourceFolder: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned
Contents: |
**/Microsoft.Android.Sdk.Linux*.symbols.nupkg
**/SignList.xml
TargetFolder: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux-symbols

- task: DeleteFiles@1
condition: and(succeeded(), or(ne(variables['AlreadyBuiltLinuxSdk'], 'true'), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true')))
inputs:
SourceFolder: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned
Contents: '*.symbols.nupkg'

- script: >
df -h &&
mkdir -p ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux &&
ln ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned/Microsoft.Android.Sdk.Linux*.nupkg
${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux &&
ln ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned/SignList.xml
${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: copy linux sdk
condition: and(succeeded(), or(ne(variables['AlreadyBuiltLinuxSdk'], 'true'), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true')))

- ${{ if eq(parameters.use1ESTemplate, true) }}:
- task: 1ES.PublishPipelineArtifact@1
displayName: upload linux sdk
condition: and(succeeded(), ne(variables['AlreadyBuiltLinuxSdk'], 'true'))
inputs:
artifactName: ${{ parameters.nugetArtifactName }}
targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux

- task: 1ES.PublishPipelineArtifact@1
displayName: upload linux sdk symbols
condition: and(succeeded(), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true'))
inputs:
artifactName: ${{ parameters.nugetArtifactName }}-symbols
targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux-symbols
- ${{ else }}:
- task: PublishPipelineArtifact@1
displayName: upload linux sdk
condition: and(succeeded(), ne(variables['AlreadyBuiltLinuxSdk'], 'true'))
inputs:
artifactName: ${{ parameters.nugetArtifactName }}
targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux

- task: PublishPipelineArtifact@1
displayName: upload linux sdk symbols
condition: and(succeeded(), ne(variables['AlreadyBuiltLinuxSdkSymbols'], 'true'))
inputs:
artifactName: ${{ parameters.nugetArtifactName }}-symbols
targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-linux-symbols

- template: /build-tools/automation/yaml-templates/upload-results.yaml
parameters:
xaSourcePath: ${{ parameters.xaSourcePath }}
Expand Down
2 changes: 0 additions & 2 deletions build-tools/automation/yaml-templates/build-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ parameters:
dependsOnResult: ''
jobName: linux_build_create_sdk_pack
jobDisplayName: Linux > Build
nugetArtifactName: $(LinuxNuGetArtifactName)
repositoryAlias: self
stageName: linux_build
stageDisplayName: Linux
Expand Down Expand Up @@ -49,5 +48,4 @@ stages:
parameters:
buildResultArtifactName: ${{ parameters.buildResultArtifactName }}
xaSourcePath: ${{ parameters.xaSourcePath }}
nugetArtifactName: ${{ parameters.nugetArtifactName }}
use1ESTemplate: ${{ parameters.use1ESTemplate }}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ steps:
artifactName: $(NuGetArtifactName)
downloadPath: ${{ parameters.xaSourcePath }}/bin/Build${{ parameters.configuration }}/nuget-unsigned

- task: DownloadPipelineArtifact@2
inputs:
artifactName: $(LinuxNuGetArtifactName)
downloadPath: ${{ parameters.xaSourcePath }}/bin/Build${{ parameters.configuration }}/nuget-unsigned
condition: and(succeeded(), eq(variables['agent.os'], 'Linux'))

- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml
parameters:
Expand Down
Loading
Loading