Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

Classic Item Groups? #40

@jonpryor

Description

@jonpryor

From the description:

Starting from a .NET 6 project, adds the ability to target legacy Xamarin target frameworks such as monoandroid11.0 or xamarin.ios10.

How much additional work should be expected? Let's try this out:

dotnet new android -n xls-def-net6
cd xls-def-net6
sed -i .bk 's,^<Project Sdk="Microsoft.NET.Sdk">,<Project Sdk="Xamarin.Legacy.Sdk/0.1.0-alpha2">,g' xls-def-net6.csproj
dotnet build

Builds with $(TargetFramework)=net6.0-android. Now let's multitarget:

sed -i .bk2 's,<TargetFramework>net6.0-android</TargetFramework>,<TargetFrameworks>monoandroid12.0;net6.0-android</TargetFrameworks>,g' xls-def-net6.csproj
dotnet build

This -- predictably in retrospect -- fails to build:

MainActivity.cs(1,1): error CS8400: Feature 'file-scoped namespace' is not available in C# 8.0. Please use language version 10.0 or greater.

OK, so we update xls-def-net6.csproj so that $(ImplicitUsings)=disable, update MainActivity.cs so that it compiles without implicit usings, and…

MainActivity.cs(14,33): error CS0117: 'Resource' does not contain a definition for 'Layout'

Thus, the question: "how much" work is expected to target a Classic SDK when starting from .NET 6?

I can get this "default .NET 6. project" to build monoandroid12.0 by adding:

  <ItemGroup>
    <AndroidResource Include="Resources\**\*" />
    <AndroidResource Remove="Resources\AboutResources.txt" />
  </ItemGroup>

Should this be expected? Should we add some default item groups for Classic?

What about creating .apk/.aab files? dotnet build -t:SignAndroidPackage doesn't work:

xls-def-net6.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.

You can set $(AndroidBuildApplicationPackage)=True:

% dotnet build -p:AndroidBuildApplicationPackage=True
% ls -l bin/Debug/*/*.apk
-rw-r--r--  1 jon  staff  13959540 Jul 12 15:20 bin/Debug/monoandroid12.0/com.companyname.xls_def_net6-Signed.apk
-rw-r--r--  1 jon  staff  13945727 Jul 12 15:20 bin/Debug/monoandroid12.0/com.companyname.xls_def_net6.apk
-rw-r--r--  1 jon  staff   2493165 Jul 12 15:18 bin/Debug/net6.0-android/com.companyname.xls_def_net6-Signed.apk
-rw-r--r--  1 jon  staff   2482972 Jul 12 15:17 bin/Debug/net6.0-android/com.companyname.xls_def_net6.apk

Is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions