49 lines
2.3 KiB
Markdown
49 lines
2.3 KiB
Markdown
# mono-apphost
|
|
You created a C# program targeting dotnet6 or newer but users don't want to download and install 200 MB runtime from microsoft website? Here is the solution - portable and small (30 MB) runtime.
|
|
|
|
Original mono project was discontinued, but fortunately microsoft has their own [fork of mono runtime](https://github.com/dotnet/runtime/tree/main/src/mono) in dotnet runtime repository. It is still used in mobile development and wasm, so they continue to update it.
|
|
|
|
|
|
## Building
|
|
1. Clone the repository with submodules
|
|
```sh
|
|
git clone --recurse-submodules --depth 1 https://timerix.ddns.net/git/Timerix/mono-apphost.git
|
|
```
|
|
|
|
2. Install [cbuild v2.3](https://timerix.ddns.net/git/Timerix/cbuild/releases/)
|
|
|
|
```sh
|
|
ln -s SDL2_HEADERS_DIRECTORY_ABSOLUTE_PATH -T dependencies/include/SDL2
|
|
```
|
|
|
|
3. Download and extract mono runtime nuget package
|
|
- default version
|
|
```sh
|
|
cbuild download_mono_from_nuget
|
|
```
|
|
- or some specific version ([list of versions](https://www.nuget.org/packages/Microsoft.NETCore.App.Runtime.Mono.linux-x64/#versions-body-tab))
|
|
```sh
|
|
cbuild download_mono_from_nuget=x.y.z
|
|
```
|
|
- or build your own .nupkg from [dotnet source code](https://github.com/dotnet/runtime/tree/main/src/mono)
|
|
```sh
|
|
git clone --depth 1 -b v10.0.8 https://github.com/dotnet/runtime dotnet-runtime
|
|
cd dotnet-runtime
|
|
./build.sh mono+libs+packs.product --runtimeFlavor Mono --usemonoruntime --configuration Release --verbosity normal /p:DisableCrossgen=true
|
|
```
|
|
- find `Microsoft.NETCore.App.Runtime.*.nupkg` in `artifacts/packages/Release/Shipping/`.
|
|
- copy `runtimes/*/native/include/mono-2.0/mono` to `./dependencies/include/`
|
|
- copy shared library files from `runtimes/*native/` to `./dependencies/precompiled/` except `System.Private.CoreLib.dll`, it must be in `./dependencies/precompiled/mono-libs`
|
|
- copy C# standard library from `runtimes/*/lib/net10.0/` to `./dependencies/precompiled/mono-libs`
|
|
|
|
4. Compile the program
|
|
```sh
|
|
cbuild build_exec_dbg
|
|
```
|
|
|
|
5. Create program config
|
|
- copy `./mono-apphost.toml.default` to `./bin/mono-apphost.toml`
|
|
- change `main_assembly_path`
|
|
|
|
6. Copy files from `./bin/` to your C# program build dir
|