2023-11-27 16:27:25 +01:00
2023-11-09 16:25:11 +01:00
2023-11-27 16:19:56 +01:00
2023-12-05 15:15:53 +01:00

CSharp to Flutter

Requirements

All the following tools must be in your PATH :

Quick start

Warning

Your dotnet project must be at the root of this repository

Simply run the build script

./build.sh -i MyLib.Managed

More advanced usage:

Context: You want to build a library named AwesomeFeature for Android only, and you have the Android NDK installed in $ANDROID_NDK_ROOT but not in $ANDROID_NDK_HOME .

./build.sh -i AwesomeFeature --ndk $ANDROID_NDK_ROOT --no-ios

session recording

Note

Open the recording with asciinema or by clicking on the image above

Usage

Usage: ./build.sh [options]
Options:
  -h, --help     Print this help and exit
  -i             Input project name (required)
  -g             Generated project name (default: <input-project-name>. Generated)
  -o             Output folder name (default: libs)
  -y             Assume yes to all prompts
  --ndk          Android NDK path (default: ANDROID_NDK_HOME environment variable)
  --no-android   Disable Android build (default: false)
  --no-ios       Disable iOS build (default: false)
  --input-spec   Input project . NET spec (default: net8.0)
  --output-spec  Output project . NET spec (default: net8.0)

What is this?

This script:

  • Run dotnet publish on the CoreRT managed library to get intermediate dlls
  • Copy configuration files templates
  • Android:
    • Run beyondnetgen to generate the C header file and the unmanaged csharp code
    • Build a complete intermediate csproject with the unmanaged csharp code and the generated header file
    • Run dotnet publish on the unmanaged csharp code for the target platforms.
  • iOS:
    • Run beyondnetgen and follow full process to get xframework
  • Copy the generated files to the output folder

Notes for external dependencies

Sometimes, you need to use external dependencies in your library. For example, your library may use Autofac or Newtonsoft.Json.

In this case, you need to add the dependencies as DLL assemblies in the external folder.

Warning

You must modify the csproj of the original library to reference the external dependencies.

<!-- In Dali.Toolkit for example, replace original references by this -->
<ItemGroup>
  <!-- Need to use dll ref here -->
  <Reference Include="../external/Autofac.dll" />
</ItemGroup>

Then during the build, the script will automatically add the external dependencies to the generated project.

Description
No description provided
Readme 30 MiB
Languages
C# 64.4%
Shell 34.9%
Batchfile 0.7%