Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.
/ dotnet-native-lib Public archive

Example of how to build a .NET native library for another programs

License

Notifications You must be signed in to change notification settings

UnixY2K/dotnet-native-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET Library for Native Apps

dotnet AOT support is now out, this project will be archived as it is now officially suported

Steps from scratch

  • 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>

Cpp steps

  • 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>

About

Example of how to build a .NET native library for another programs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published