Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/enable-marshal-methods
Browse files Browse the repository at this point in the history
* main:
  [trimming] fix custom applications for `TrimMode=full` (#8936)
  It's ".NET for Android", not ".NET Android" (#8933)
  • Loading branch information
grendello committed May 14, 2024
2 parents 8c7aa5d + 98c1063 commit 9275fa3
Show file tree
Hide file tree
Showing 214 changed files with 644 additions and 654 deletions.
2 changes: 1 addition & 1 deletion .gdn/tsaoptions-v2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"codebaseName": "xamarin.android_main",
"codebaseName": "dotnet.android_main",
"notificationAliases": [
"dotnet-android-eng@microsoft.com"
],
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build All Xamarin.Android",
"label": "Build All .NET for Android",
"type": "shell",
"windows":{ "command": ".\\build.cmd ${input:buildtype}"},
"linux":{"command": "./build.sh ${input:buildtype}"},
Expand Down Expand Up @@ -231,4 +231,4 @@
]
},
]
}
}
12 changes: 6 additions & 6 deletions Documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Getting Started

* [Installing the Xamarin.Android SDK](https://developer.xamarin.com/guides/android/getting_started/installation/)
* [Xamarin.Android Documentation](https://developer.xamarin.com/guides/android/)
* [Xamarin.Android API Documentation](https://developer.xamarin.com/api/root/MonoAndroid-lib/)
* [Installing the .NET for Android SDK](https://developer.xamarin.com/guides/android/getting_started/installation/)
* [.NET for Android Documentation](https://learn.microsoft.com/dotnet/android/)
* [.NET for Android API Documentation](https://learn.microsoft.com/en-us/dotnet/api/?preserve-view=true&view=net-android-34.0)


# Project Docs
Expand All @@ -30,9 +30,9 @@

* [Build System Configuration](building/configuration.md)
* [Build Dependencies for Linux and macOS](building/unix/dependencies.md)
* [Building Xamarin.Android on Linux and macOS](building/unix/instructions.md)
* [Building .NET for Android on Linux and macOS](building/unix/instructions.md)
* [Build Dependencies for Windows](building/windows/dependencies.md)
* [Building Xamarin.Android on Windows](building/windows/instructions.md)
* [Building .NET for Android on Windows](building/windows/instructions.md)


# Development Workflow
Expand All @@ -50,4 +50,4 @@

# Other Information

* [Wikipedia Entry for Xamarin.Android](https://en.wikipedia.org/wiki/Mono_(software)#Xamarin.Android)
* [Wikipedia Entry for .NET for Android](https://en.wikipedia.org/w/index.php?title=.NET_for_Android&redirect=yes)
4 changes: 2 additions & 2 deletions Documentation/binfmt_misc-warning-Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Your Linux appears to have support for binfmt_misc kernel module enabled.
The module makes it possible to execute non-Linux binaries if the appropriate
interpreter for the given format is available.
Your machine is configured to handle Windows PE executables either via Mono or
Wine. It will make the Xamarin.Android build fail IF you choose to build the
Wine. It will make the .NET for Android build fail IF you choose to build the
Windows cross-compilers by enabling the 'mxe-Win32' or 'mxe-Win64' host targets.

You can disable the binfmt_misc module by issuing the following command as root
before building Xamarin.Android:
before building .NET for Android:

echo 0 > /proc/sys/fs/binfmt_misc/status

Expand Down
2 changes: 1 addition & 1 deletion Documentation/building/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Build Configuration

The Xamarin.Android build is heavily dependent on MSBuild, with the *intention*
The .NET for Android build is heavily dependent on MSBuild, with the *intention*
that it should (eventually?) be possible to build the project simply by
checking out the repo, loading `Xamarin.Android.sln` into an IDE, and Building
the solution. (This isn't currently possible, and may never be, but it's
Expand Down
2 changes: 1 addition & 1 deletion Documentation/building/unix/dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build Dependencies for Linux and macOS

Building Xamarin.Android requires:
Building .NET for Android requires:

* [Homebrew](#homebrew)
* [Latest Mono](#mono-sdk)
Expand Down
34 changes: 7 additions & 27 deletions Documentation/building/unix/instructions.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Building Xamarin.Android on Linux and macOS
# Building .NET for Android on Linux and macOS

Building Xamarin.Android on Linux and macOS relies on GNU make and
Building .NET for Android on Linux and macOS relies on GNU make and
MSBuild via the `msbuild` command (within Mono). MSBuild via `xbuild`
can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.

# Building Xamarin.Android
# Building .NET for Android

1. Install the [build dependencies](dependencies.md).

Expand Down Expand Up @@ -58,11 +58,11 @@ can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.
2019][xamdevsummit] with a full walkthrough. Even though the demo was
on Windows, many of the concepts should still apply:

[![Build Xamarin.Android](https://img.youtube.com/vi/8qaQleb6Tbk/maxresdefault.jpg)][xamdevsummit]
[![Build .NET for Android](https://img.youtube.com/vi/8qaQleb6Tbk/maxresdefault.jpg)][xamdevsummit]

[xamdevsummit]: https://youtu.be/8qaQleb6Tbk

# Creating a local .NET android Workload
# Creating a local .NET for Android Workload

`make prepare` provisions a specific build of .NET to
`bin/$(Configuration)/dotnet`.
Expand Down Expand Up @@ -95,12 +95,12 @@ See the [One .NET Documentation](../../guides/OneDotNet.md) for further details.
# Creating installers

Once `make all` or `make jenkins` have completed, macOS (.pkg),
Windows (.vsix), and .NET android workload .nupkg files
Windows (.vsix), and .NET for Android workload .nupkg files
can be built with:

make create-installers

Alternatively, .NET android workload packs can be built with:
Alternatively, .NET for Android workload packs can be built with:

make create-nupkgs
# -or-
Expand Down Expand Up @@ -351,23 +351,3 @@ For example, to rebuild Mono for armeabi-v7a:
$ msbuild /t:_InstallRuntimes src/mono-runtimes/mono-runtimes.csproj


# How do I rebuild BCL assemblies?

The Xamarin.Android Base Class Library assemblies, such as `mscorlib.dll`,
are built within `external/mono`, using Mono's normal build system:

# This updates external/mono/mcs/class/lib/monodroid/ASSEMBLY.dll
$ make -C external/mono/mcs/class/ASSEMBLY PROFILE=monodroid

Alternatively, if you want to rebuild *all* the assemblies, the "host"
Mono needs to be rebuilt. Note that the name of the "host" directory
varies based on the operating system you're building from:

$ make -C src/mono-runtimes/obj/Debug/host-Darwin

Once the assemblies have been rebuilt, they can be copied into the appropriate
Xamarin.Android SDK directory by using the `_InstallBcl` target:

# This updates bin/$(Configuration)/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ASSEMBLY.dll
$ msbuild src/mono-runtimes/mono-runtimes.csproj /t:_InstallBcl

4 changes: 2 additions & 2 deletions Documentation/building/windows/dependencies.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Build Dependencies for Windows

Building Xamarin.Android requires:
Building .NET for Android requires:

* An existing installation of the Xamarin.Android SDK and the Android SDK
* An existing installation of the .NET for Android SDK and the Android SDK
* The .NET Framework 3.5 – 4.7 development tools
* Git for Windows
* The Java Development Kit (JDK)
Expand Down
12 changes: 6 additions & 6 deletions Documentation/building/windows/instructions.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Building Xamarin.Android on Windows
# Building .NET for Android on Windows

Building Xamarin.Android on Windows requires .NET and the `msbuild` command
Building .NET for Android on Windows requires .NET and the `msbuild` command
be available within the Command-Line environment.
(The **Developer Command Prompt** that Visual Studio installs is sufficient.)

MSBuild version 15 or later is required.

# Building Xamarin.Android
# Building .NET for Android

1. Install the [build dependencies](dependencies.md).

Expand Down Expand Up @@ -80,13 +80,13 @@ So for example:
[windows_path]: https://www.java.com/en/download/help/path.xml
[set_alias]: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-6

# Creating a local .NET android Workload
# Creating a local .NET for Android Workload

`dotnet msbuild Xamarin.Android.sln -t:Prepare` provisions a
specific build of .NET to `bin\$(Configuration)\dotnet`.

Once the prepare target is complete, you can set up a local
.NET android workload install with:
.NET for Android workload install with:

dotnet-local.cmd build Xamarin.Android.sln -t:BuildDotNet -m:1

Expand Down Expand Up @@ -121,7 +121,7 @@ See the [One .NET Documentation](../../guides/OneDotNet.md) for further details.
# Creating installers

Once `dotnet msbuild Xamarin.Android.sln -t:Prepare` is complete,
.NET android workload packs can be built with:
.NET for Android workload packs can be built with:

dotnet-local.cmd build Xamarin.Android.sln -t:BuildDotNet,PackDotNet -m:1

Expand Down
4 changes: 2 additions & 2 deletions Documentation/guides/AndroidAssetPacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ as required.
There are two types of `pack`: Feature packs and Asset packs.
*Feature* pack contains *non-native* Java code and other resources.
Code in these types of `pack` can be launched via the `Context.StartActivity()`
API call. At this time due to various constraints .NET Android cannot support
API call. At this time due to various constraints .NET for Android cannot support
Feature packs.

*Asset* packs contain *only*
Expand Down Expand Up @@ -232,4 +232,4 @@ issues though.
2. There is no IDE support for building this type of project.

Having the user go through a number of hoops to implement this for
.NET Android or .NET MAUI is not ideal.
.NET for Android or .NET MAUI is not ideal.
6 changes: 3 additions & 3 deletions Documentation/guides/D8andR8.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is the D8 and R8 integration specification for Xamarin.Android.
This is the D8 and R8 integration specification for .NET for Android.

# What is D8? What is R8?

Expand Down Expand Up @@ -89,7 +89,7 @@ Usage: r8 [options] <input-files>
--help # Print this message.
```

# What did Xamarin.Android do *before* D8/R8?
# What did .NET for Android do *before* D8/R8?

In other words, what is currently happening *before* we introduce D8/R8 support?

Expand All @@ -116,7 +116,7 @@ In other words, what is currently happening *before* we introduce D8/R8 support?

# What does this process look like with D8 / R8 enabled?

Xamarin.Android now has two new MSBuild tasks: `<R8/>` and `<D8/>`.
.NET for Android now has two new MSBuild tasks: `<R8/>` and `<D8/>`.

1. The [Javac](https://github.com/xamarin/xamarin-android/blob/221a2190ebb3aaec9ecd9b1cf8f7f6174c43153a/src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs)
MSBuild task will remain unchanged.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/guides/InstallBuildsFromMain.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you get the error:
error XA5207: Could not find android.jar for API level 32.
This means the Android SDK platform for API level 32 is not installed.
Either install it in the Android SDK Manager (Tools > Android > Android SDK Manager...),
or change the Xamarin.Android project to target an API version that is installed.
or change your .NET for Android project to target an API version that is installed.
```

On Windows, if your Android SDK is located in `C:\Program Files
Expand Down
18 changes: 9 additions & 9 deletions Documentation/guides/MSBuildBestPractices.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This guide is a work-in-progress, but really has two main goals:
- What are good MSBuild practices, in general?
- What are good MSBuild practice in relation to what we already have
going on in Xamarin.Android MSBuild targets?
going on in .NET for Android MSBuild targets?

## Debugging MSBuild Tasks

Expand All @@ -19,7 +19,7 @@ Waiting for debugger to attach (dotnet PID 13001). Press enter to continue...

You can then use VS or VSCode to attach to this process and debug you tasks.

In the case of .NET Android we need to do a couple of thing first though. Firstly
In the case of .NET for Android we need to do a couple of thing first though. Firstly
we need to disable the use of `ILRepacker` on the `Xamarin.Android.Build.Tasks`
assembly. This is because `ILRepacker` does NOT handle debug symbols very well.
Assemblies it generates seem to be JIT optimized so the debugger will not load
Expand Down Expand Up @@ -65,7 +65,7 @@ Once MSBuild starts it will print the following
Waiting for debugger to attach (dotnet PID xxxx). Press enter to continue...
```

You need to copy the PID value so we can use this in the IDE. For Visual Studio you can use the `Attach to Process` menu option, while you have the Xamarin.Android.sln solution open. For VSCode open the workspace then use the `Attach to Process` Run and Debug option. You will be prompted for the PID and it will then connect.
You need to copy the PID value so we can use this in the IDE. For Visual Studio you can use the `Attach to Process` menu option, while you have the `Xamarin.Android.sln` solution open. For VSCode open the workspace then use the `Attach to Process` Run and Debug option. You will be prompted for the PID and it will then connect.

Once connected go back to your command prompt and press ENTER so that the MSBuild process can continue.

Expand Down Expand Up @@ -378,7 +378,7 @@ evaluates `$(MSBuildAllProjects)` since [MSBuild 16.0][allprojects].

> NOTE: You might consider using `@(_AndroidMSBuildAllProjects)`
> instead of `$(MSBuildAllProjects)` when working on the
> Xamarin.Android MSBuild targets. We have excluded the `*.csproj.user`
> .NET for Android MSBuild targets. We have excluded the `*.csproj.user`
> file for performance reasons.
One pitfall, is this `_GenerateDocumentation` example *must* touch the
Expand Down Expand Up @@ -540,7 +540,7 @@ Or if you want to cache across multiple-builds, use
> Use `as` for casts to avoid any unexpected `InvalidCastException`'s.
> Use the `RegisterTaskObjectAssemblyLocal()` or
> `GetRegisteredTaskObjectAssemblyLocal()` extension methods within
> the Xamarin.Android codebase.
> the .NET for Android codebase.
To *test* and validate your MSBuild task's use of
`RegisteredTaskObjectLifetime.AppDomain` you have two choices:
Expand Down Expand Up @@ -571,9 +571,9 @@ an implementation of MSBuild out-of-process nodes yet._
[static_csharp]: https://softwareengineering.stackexchange.com/questions/161222/dont-use-static-in-c
[project_system]: https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools

# Best Practices for Xamarin.Android MSBuild targets
# Best Practices for .NET for Android MSBuild targets

## Naming in Xamarin.Android targets
## Naming in .NET for Android targets

As mentioned [above](/MSBuildBestPractices.md#naming), a good amount
of consideration should be done before adding new public-facing
Expand All @@ -583,11 +583,11 @@ since an obvious feature flag will be needed to enable it.
The main thing to keep in mind here is that almost all of our
public-facing MSBuild properties should be prefixed with `Android`.
This is a good convention so it is easy to know which properties are
specific to Xamarin.Android, and this will prevent them from
specific to .NET for Android, and this will prevent them from
conflicting with MSBuild properties from other products. All MSBuild
properties are effectively "global variables"...

## Xamarin.Android MSBuild Task base classes
## .NET for Android MSBuild Task base classes

We have a few base classes to simplify error handling, `async` /
`await` usage, etc.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/guides/MSBuildReferenceAssemblies.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The developer makes a change to something within `Referenced.csproj`.

Question: Does `Referencer.csproj` need to be rebuilt?

In the "original" MSBuild world -- the world that Xamarin.Android
In the "original" MSBuild world -- the world that .NET for Android
still lives in -- the answer is *yes*, `Referencer.csproj` *must
**always*** be rebuilt, because the change to `Referenced.csproj`
*may* contain an API breaking change which would prevent
Expand Down
14 changes: 7 additions & 7 deletions Documentation/guides/OneDotNet.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# .NET 6 and Xamarin.Android
# .NET for Android

_NOTE: this document is very likely to change, as the requirements for
.NET 6 are better understood._

A .NET 6 project for a Xamarin.Android application will look something
A .NET 6 project for a .NET for Android application will look something
like:

```xml
Expand Down Expand Up @@ -31,7 +31,7 @@ Changes for bindings projects are documented [here][binding].
## .NET Configuration Files

No support for [configuration files][config] such as `Foo.dll.config`
or `Foo.exe.config` is available in Xamarin.Android projects targeting
or `Foo.exe.config` is available in .NET for Android projects targeting
.NET 6. [`<dllmap>`][dllmap] configuration elements are not supported
in .NET Core at all, and other element types for compatibility
packages like [System.Configuration.ConfigurationManager][nuget] have
Expand Down Expand Up @@ -201,7 +201,7 @@ turn these settings off:
## dotnet cli

There are currently a few "verbs" we are aiming to get working in
Xamarin.Android:
.NET for Android:

dotnet new
dotnet build
Expand Down Expand Up @@ -250,12 +250,12 @@ to produce a self-contained "app" happens:

https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#readytorun-images

However, for Xamarin.Android, `dotnet build` should produce something
However, for .NET for Android, `dotnet build` should produce something
that is runnable. This basically means we need to create an `.apk` or
`.aab` file during `build`. We will need to reorder any MSBuild tasks
from the dotnet SDK, so that they will run during `build`.

This means Xamarin.Android would run:
This means .NET for Android would:

* Run `aapt` to generate `Resource.designer.cs` and potentially emit
build errors for issues in `@(AndroidResource)` files.
Expand All @@ -275,7 +275,7 @@ copy the output to a `publish` directory on disk.
_NOTE: Behavior inside IDEs will differ. The `Build` target will not
produce an `.apk` file if `$(BuildingInsideVisualStudio)` is `true`.
IDEs will call the `Install` target for deployment, which will produce
the `.apk` file. This behavior matches "legacy" Xamarin.Android._
the `.apk` file.

[illink]: https://github.com/mono/linker/blob/master/src/linker/README.md

Expand Down
Loading

0 comments on commit 9275fa3

Please sign in to comment.