User Tools

Site Tools


guides:tutorials:netlinux

.NET Core, Linux and MacOS

Documentation | Tutorials | .NET Core, Linux and MacOS

Starting with version 11.45. Developer Kernel offers .NET Standard libraries available via private NuGet Server.

Preparations

This library can be used directly to run non-visual .NET Core applications also on Unix like platforms. However, some additional steps must be performed:

Standalone Linux and WSL

  • Install .NET Core. Follow https://docs.microsoft.com/en-us/dotnet/core/install/linux.
    For Ubuntu 20.04 you can use:
    sudo apt update
    sudo apt upgrade
    wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    sudo dpkg -i packages-microsoft-prod.deb
    sudo apt-get update
    sudo apt-get install -y apt-transport-https
    sudo apt-get update
    sudo apt-get install -y dotnet-sdk-3.1
  • Install libgdiplus libraries responsible for GDI rendering on Linux: \\
    sudo apt-get install -y --allow-unauthenticated libc6-dev libgdiplus libx11-dev
    sudo rm -rf /var/lib/apt/lists/*
  • Install Windows compatible fonts (optional):
    sudo apt install ttf-mscorefonts-installer

Linux and Docker

  • If debugged from Visual Studio - use Visual Studio built-in docker support.
  • However, to use TGIS_ViewerBMP libgdiplus must be installed. Therefore modifying dockerfile is required:

    Before:
    1. #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
    2.  
    3. FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
    4. WORKDIR /app
    5.  
    6. ...

    After:

    1. #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
    2.  
    3. FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
    4. #{ new content
    5. RUN apt-get update \
    6. && apt-get install -y --allow-unauthenticated \
    7. libc6-dev \
    8. libgdiplus \
    9. libx11-dev \
    10. && rm -rf /var/lib/apt/lists/*
    11. #}
    12. WORKDIR /app
    13.  
    14. ...

    Sample for ASPNET 5.0:

    1. #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
    2.  
    3. FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
    4. #{ new content
    5. RUN apt-get update \
    6. && apt-get install -y --allow-unauthenticated \
    7. libc6-dev \
    8. libgdiplus \
    9. libx11-dev \
    10. && rm -rf /var/lib/apt/lists/*
    11. #}
    12. WORKDIR /app
    13. EXPOSE 80
    14. EXPOSE 443
    15.  
    16. ...

For actual mcr.* path for Docker Linux version look at: ASP.NET Core Runtime.

MacOS

  • install .NET Core
  • install Homebrew
  • add nuget package runtime.osx.10.10-x64.CoreCompat.System.Drawing
  • add the following line to the .csproj file in a PropertyGroup section:
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
  • create a file named runtimeconfig.template.json in the same directory as your project file containing:
{
      "configProperties": {
         "System.Drawing.EnableUnixSupport": true
      }
}

Since .NET 6 System.Drawing.Common is only supported on Windows. On non-Windows operating systems a TypeInitializationException exception is thrown with PlatformNotSupportedException as the inner exception. Prior to .NET 6, using the System.Drawing.Common package did not produce any compile-time warnings, and no run-time exceptions were thrown.

Android

Does not work at this moment due to some technical issues.

Debugging

We currently tested the scenario when the application is debugged directly from Visual Studio on the Windows platform. In such a situation debugging on Linux is a matter of remote debugging.

Layers support

There is a limitation of running layers built on specific drivers like: sqlite3, OCI, and LIBPQ. Such layers (e.g. TGIS_LayerSqlSqlite) are available and work properly on Windows platforms. On non-Windows however, data should be accessed via (e.g. TGIS_LayerSqlAdoNet).

See also List of supported layer formats.

2022/10/11 19:55

Page Tools