Skip to content

Conversation

@pjcollins
Copy link
Member

@pjcollins pjcollins commented Apr 5, 2022

Fixes: #6914

The Microsoft.Android @(KnownFrameworkReference) will now declare
targeting and runtime pack metadata that is based on the
$(TargetPlatformVersion) of the project file. The only exception to
this rule is when '$(TargetPlatformVersion)' == '31.0'; in this case the
project will use an API 31 ref pack with API 32 runtime packs. The
inline Microsoft.Android.Sdk.BundledVersions.targets file content
has been moved into a separate file to improve the readability of the
@(KnownFrameworkReference) element.

Breakdown of supported $(TargetFramework) -> ref/runtime pack used:

$(TargetFramework) Targeting Pack Runtime Pack
net6.0-android Microsoft.Android.Ref.31 Microsoft.Android.Runtime.32
net6.0-android31.0 Microsoft.Android.Ref.31 Microsoft.Android.Runtime.32
net6.0-android32.0 Microsoft.Android.Ref.32 Microsoft.Android.Runtime.32
net6.0-android33.0 Microsoft.Android.Ref.33 Microsoft.Android.Runtime.33

Tests have been updated accordingly, and they will now use a dynamic
test case source that should make sure we don't miss any coverage when
making future updates to $(AndroidDefaultTargetDotnetApiLevel),
$(AndroidLatestStableApiLevel), and $(AndroidLatestUnstableApiLevel).

If an unsupported $(TargetFramework) is used in a project file the
following errors will now be displayed:

"test.csproj" (_GenerateRestoreGraphProjectEntry target) (1:5) ->
   (ProcessFrameworkReferences target) ->
     C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Ref.25' was not present in workload manifests.
     C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-arm' was not present in workload manifests.
     C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-arm64' was not present in workload manifests.
     C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-x86' was not present in workload manifests.
     C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-x64' was not present in workload manifests.

Additionally, the build has been updated to produce a reference pack for
the API level declared in $(AndroidDefaultTargetDotnetApiLevel), if it
is not the same as $(AndroidLatestStableApiLevel). This will allow
the default net6.0-android target framework to use an up to date
Mono.Android.dll, instead of an older preview version from NuGet.org.

@pjcollins pjcollins marked this pull request as ready for review April 8, 2022 17:48
@pjcollins
Copy link
Member Author

Related: https://discord.com/channels/732297728826277939/732297837953679412/962024444342173727

This has an added benefit of making sure we don't miss bug fixes, without having to track all of them.

@pjcollins pjcollins marked this pull request as draft April 11, 2022 18:09
The Microsoft.Android `@(KnownFrameworkReference)` will now delcare
targeting and runtime pack metadata that is based on the
`$(TargetPlatformVersion)` of the project file.  The only exception to
this rule is when '$(TargetPlatformVersion)' == '31.0'; in this case the
project will use an API 31 ref pack with API 32 runtime packs.  The
inline `Microsoft.Android.Sdk.BundledVersions.targets` file content
has been moved into a separate file to improve the readability of the
`@(KnownFrameworkReference)` element.

Breakdown of supported `$(TargetFramework)` -> ref/runtime pack used:

| `$(TargetFramework)` | Targeting Pack | Runtime Pack |
| -------------------- | -------------- | ------------ |
| net6.0-android     | Microsoft.Android.Ref.31 | Microsoft.Android.Runtime.32 |
| net6.0-android31.0 | Microsoft.Android.Ref.31 | Microsoft.Android.Runtime.32 |
| net6.0-android32.0 | Microsoft.Android.Ref.32 | Microsoft.Android.Runtime.32 |
| net6.0-android33.0 | Microsoft.Android.Ref.33 | Microsoft.Android.Runtime.33 |

Tests have been updated accordingly, and they will now use a dynamic
test case source that should make sure we don't miss any coverage when
making future updates to `$(AndroidDefaultTargetDotnetApiLevel)`,
`$(AndroidLatestStableApiLevel)`, and `$(AndroidLatestUnstableApiLevel)`.

If an unsupported `$(TargetFramework)` is used in a project file the
following errors will now be displayed:

    "test.csproj" (_GenerateRestoreGraphProjectEntry target) (1:5) ->
       (ProcessFrameworkReferences target) ->
         C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Ref.25' was not present in workload manifests.
         C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-arm' was not present in workload manifests.
         C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-arm64' was not present in workload manifests.
         C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-x86' was not present in workload manifests.
         C:\Program Files\dotnet\sdk\6.0.300-preview.22211.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error : NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Runtime.25.android-x64' was not present in workload manifests.

Additionally, the build has been updated to produce a reference pack for
the API level declared in `$(AndroidDefaultTargetDotnetApiLevel)`, if it
is not the same as `$(AndroidLatestStableApiLevel)`.  This will allow
the default `net6.0-android` target framework to use an up to date
Mono.Android.dll, instead of an older preview version from NuGet.org.
@pjcollins pjcollins changed the title [build] Produce an API 31 ref pack [One .NET] Fix targeting API 33, build API 31 ref pack Apr 12, 2022
@pjcollins pjcollins marked this pull request as ready for review April 12, 2022 20:11
@pjcollins pjcollins requested a review from grendello as a code owner April 12, 2022 20:11
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍, assuming that CI ends up green.

@pjcollins pjcollins merged commit 0ab3db0 into dotnet:main Apr 13, 2022
@pjcollins pjcollins deleted the build-api-31-ref branch April 13, 2022 14:22
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
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.

.NET 6 API-31 reference pack is not being updated

3 participants