Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/flathub/org.freedesktop.sdk.extension.dotnet8


https://github.com/flathub/org.freedesktop.sdk.extension.dotnet8

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# .NET 8 SDK extension

## How to use
You need to add following lines to flatpak manifest:

```json
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.dotnet8"
],
"build-options": {
"append-path": "/usr/lib/sdk/dotnet8/bin",
"append-ld-library-path": "/usr/lib/sdk/dotnet8/lib",
"env": {
"PKG_CONFIG_PATH": "/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/sdk/dotnet8/lib/pkgconfig"
}
},
```

### Scripts
* `install.sh` - copies dotnet runtime to package.
* `install-sdk.sh` - copies dotnet SDK to package.

### Publishing project

```json
"build-commands": [
"install.sh",
"dotnet publish -c Release YourProject.csproj",
"cp -r --remove-destination /run/build/YourProject/bin/Release/net8.0/publish/ /app/bin/",
]
```

### Using nuget packages
If you want to use nuget packages it is recommended to use the [Flatpak .NET Generator](https://github.com/flatpak/flatpak-builder-tools/tree/master/dotnet) tool. It generates sources file that can be included in manifest.

```json
"build-commands": [
"install.sh",
"dotnet publish -c Release --source ./nuget-sources YourProject.csproj",
"cp -r --remove-destination /run/build/YourProject/bin/Release/net8.0/publish/ /app/bin/"
],
"sources": [
"sources.json",
"..."
]
```

### Publishing self contained app and trimmed binaries
.NET 8 gives option to include runtime in published application and trim their binaries. This allows you to significantly reduce the size of the package and get rid of `/usr/lib/sdk/dotnet8/bin/install.sh`.

First you need to have following lines in `sources.json`. These packages are needed to build a project for specific runtime.

```json
{
"type": "file",
"url": "https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.app.runtime.linux-arm64/8.0.10/microsoft.aspnetcore.app.runtime.linux-arm64.8.0.10.nupkg",
"sha512": "805c73d94bd29ee9523469ff5e5982ac3c18da352477b52d615f6f8215686a88378c2c238e2e0a7ddd5815388b298cbe039fac808841a9a95ae78970a3cb1129",
"dest": "nuget-sources",
"dest-filename": "microsoft.aspnetcore.app.runtime.linux-arm64.8.0.10.nupkg",
"x-checker-data": {
"type": "html",
"url": "https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/8.0/latest.version",
"version-pattern": "^([\\d\\.a-z-]+)$",
"url-template": "https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.app.runtime.linux-arm64/$version/microsoft.aspnetcore.app.runtime.linux-arm64.$version.nupkg"
}
},
{
"type": "file",
"url": "https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.app.runtime.linux-x64/8.0.10/microsoft.aspnetcore.app.runtime.linux-x64.8.0.10.nupkg",
"sha512": "1415b4c698892ba1706faaa5c4d11868c27692550d1820e286b5bba63af82f2fef64b0966cddfe7ef38186bef8e0a04590cc3371663e455ce53f1c4a3f1f87f8",
"dest": "nuget-sources",
"dest-filename": "microsoft.aspnetcore.app.runtime.linux-x64.8.0.10.nupkg",
"x-checker-data": {
"type": "html",
"url": "https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/8.0/latest.version",
"version-pattern": "^([\\d\\.a-z-]+)$",
"url-template": "https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.app.runtime.linux-x64/$version/microsoft.aspnetcore.app.runtime.linux-x64.$version.nupkg"
}
},
{
"type": "file",
"url": "https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app.runtime.linux-arm64/8.0.10/microsoft.netcore.app.runtime.linux-arm64.8.0.10.nupkg",
"dest": "nuget-sources",
"dest-filename": "microsoft.netcore.app.runtime.linux-arm64.8.0.10.nupkg",
"x-checker-data": {
"type": "html",
"url": "https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/8.0/latest.version",
"version-pattern": "^([\\d\\.a-z-]+)$",
"url-template": "https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app.runtime.linux-arm64/$version/microsoft.netcore.app.runtime.linux-arm64.$version.nupkg"
}
},
{
"type": "file",
"url": "https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app.runtime.linux-x64/8.0.10/microsoft.netcore.app.runtime.linux-x64.8.0.10.nupkg",
"dest": "nuget-sources",
"dest-filename": "microsoft.netcore.app.runtime.linux-x64.8.0.10.nupkg",
"x-checker-data": {
"type": "html",
"url": "https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/8.0/latest.version",
"version-pattern": "^([\\d\\.a-z-]+)$",
"url-template": "https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app.runtime.linux-x64/$version/microsoft.netcore.app.runtime.linux-x64.$version.nupkg"
}
},
```

Then add build options:

```json
"build-options": {
"arch": {
"aarch64": {
"env" : {
"RUNTIME": "linux-arm64"
}
},
"x86_64": {
"env" : {
"RUNTIME": "linux-x64"
}
}
}
},
"build-commands": [
"mkdir -p /app/bin",
"dotnet publish -c Release --source ./nuget-sources YourProject.csproj --runtime $RUNTIME --self-contained true",
"cp -r --remove-destination /run/build/YourProject/bin/Release/net8.0/$RUNTIME/publish/* /app/bin/",
],
```