Skip to content

Commit 1a1c110

Browse files
committed
[build] Produce an API 31 ref pack
Our default `net6.0-android` target framework version is using an older API 31 reference pack that was previously published to NuGet.org. This package will be installed on project restore, however it prevents an "offline" Visual Studio installation from working out of the box. Additionally, recent changes in the MSI generation tooling for .NET workloads now produce an error when processing our WorkloadManifest.json file. That tooling now expects every pack dependency declared in the manifest to exist on disk. Update the build to produce a reference pack for the API level declared in `$(AndroidDefaultTargetDotnetApiLevel)`, if it is not the same as `$(AndroidLatestStableApiLevel)`.
1 parent 3f2e55d commit 1a1c110

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

build-tools/create-packs/Directory.Build.targets

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
<RemoveDir Directories="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned" />
5757
</Target>
5858

59+
<Target Name="_CreateDefaultRefPack"
60+
Condition=" '$(AndroidLatestStableApiLevel)' != '$(AndroidDefaultTargetDotnetApiLevel)' and Exists('$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\net6.0-android$(AndroidDefaultTargetDotnetApiLevel)\Mono.Android.dll') ">
61+
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
62+
</Target>
63+
5964
<Target Name="_CreatePreviewPacks"
6065
Condition=" '$(AndroidLatestStableApiLevel)' != '$(AndroidLatestUnstableApiLevel)' and Exists('$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\net6.0-android$(AndroidLatestUnstableApiLevel)\Mono.Android.dll') ">
6166
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidApiLevel=$(AndroidLatestUnstableApiLevel) -p:AndroidRID=android-arm -p:AndroidABI=armeabi-v7a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
@@ -66,7 +71,7 @@
6671
</Target>
6772

6873
<Target Name="CreateAllPacks"
69-
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties;GetXAVersionInfo;_CleanNuGetDirectory;_CreatePreviewPacks">
74+
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties;GetXAVersionInfo;_CleanNuGetDirectory;_CreatePreviewPacks;_CreateDefaultRefPack">
7075
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-arm -p:AndroidABI=armeabi-v7a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
7176
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-arm64 -p:AndroidABI=arm64-v8a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
7277
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-x86 -p:AndroidABI=x86-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />

build-tools/scripts/DotNet.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<Target Name="PackDotNet">
66
<MSBuild Projects="$(_Root)build-tools\xa-prep-tasks\xa-prep-tasks.csproj" />
77
<MSBuild Projects="$(_Root)Xamarin.Android.sln" Properties="DisableApiCompatibilityCheck=true" />
8+
<MSBuild
9+
Condition=" '$(AndroidLatestStableApiLevel)' != '$(AndroidDefaultTargetDotnetApiLevel)' "
10+
Projects="$(_Root)src\Mono.Android\Mono.Android.csproj"
11+
Properties="TargetFramework=net6.0;AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel);AndroidPlatformId=$(AndroidDefaultTargetDotnetApiLevel);DisableApiCompatibilityCheck=true" >
12+
</MSBuild>
813
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="CreateAllPacks" />
914
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="ExtractWorkloadPacks" />
1015
<!-- Clean up old, previously restored packages -->

src/Mono.Android/Mono.Android.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@
386386
<Target Name="GetTargetPath" />
387387

388388
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
389-
<!-- Only build the 'net6.0' version of 'Mono.Android.dll' for the latest stable Android version or higher. -->
390-
<PropertyGroup Condition=" '$(TargetFramework)' != 'monoandroid10' And '$(AndroidApiLevel)' &lt; '$(AndroidLatestStableApiLevel)' ">
389+
<!-- Only build the 'net6.0' version of 'Mono.Android.dll' for the default API level that is supported or higher. -->
390+
<PropertyGroup Condition=" '$(TargetFramework)' != 'monoandroid10' And '$(AndroidApiLevel)' &lt; '$(AndroidDefaultTargetDotnetApiLevel)' ">
391391
<BuildDependsOn></BuildDependsOn>
392392
</PropertyGroup>
393393

src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"Microsoft.Android.Ref.31": {
4545
"kind": "framework",
46-
"version": "31.0.101-preview.11.117"
46+
"version": "@WORKLOAD_VERSION@"
4747
},
4848
"Microsoft.Android.Ref.32": {
4949
"kind": "framework",

0 commit comments

Comments
 (0)