dotnet AOT support is now out, this project will be archived as it is now officially suported
- Create a new project
dotnet new classlib -o DotNetLib
- add NativeAOT support by creating a nuget config
cd DotNetLib dotnet new nugetconfig
- Add the following to the
nuget.config
file:<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/ _packaging/dotnet-experimental/nuget/v3/index.json" />
- add a reference to the compiler
dotnet add package Microsoft.DotNet.ILCompiler -v 7.0.0-*
- then you can publish the dll like this
dotnet publish /p:NativeLib=Shared /p:SelfContained=true -r <RID> -c <Configuration>
- make and build the native executable
meson builddir meson compile -C builddir
- put the library in the executable generated by meson
(buiddir/cpp)
- run it
./builddir/bin/<executable>