The below steps are tested on Ubuntu 24.04.1 LTS (on Windows Bash) with DocumentUltimate AspNetCoreCS example project.
However you can add the same commands to a docker Linux container, by prefixing the commands with RUN
1. Install the .NET SDK (it also includes the .NET Runtime for same version):
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-8.0
a. Note that Microsoft no longer supports installing older versions of SDK or Runtime via apt-get packages. So for example, if your project target framework is net6.0, you should install it manually with script method provided by Microsoft:
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel 6.0
b. As we used the script method, edit bash profile file in your home directory, i.e. the file ~/.bashrc and added these lines for being able to access dotnet commands (or if you run the lines in terminal, the env variables will exist until your terminal is closed):
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
Ref:
c. As we used the script method, we need to add .NET dependencies manually, for example for Ubuntu:
sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
libc6 \
libgcc-s1 \
libicu74 \
libssl3 \
libstdc++6 \
zlib1g
Ref:
2 . Install fonts so that DocumentViewer and conversions to PDF, display accurate text:
sudo apt-get install -y \
ttf-mscorefonts-installer \
ttf-wqy-zenhei \
fonts-arphic-ukai \
fonts-arphic-uming \
fonts-ipafont-mincho \
fonts-ipafont-gothic \
fonts-unfonts-core
You can use ls command to check/list system fonts:
ls /usr/share/fonts/truetype/msttcorefonts
ls /usr/share/fonts/truetype
If you still have font issues (wrong font, missing characters) after installing above fonts, you can copy the necessary/additional font files to /usr/local/share/fonts
For example, use this command to copy your fonts to a docker Linux container:
COPY ["Project/Fonts/*.*", "/usr/local/share/fonts/"]
3. Install System.Drawing.Common dependencies as some conversions (e.g. Excel files) still depend on it as of current version:
sudo apt install libgdiplus
Microsoft decided to make package System.Drawing.Common "Windows only" in .NET 6 and higher.
So you need to opt-in to be able to use System.Drawing.Common package on Linux.
Edit your project's .csproj file and add these lines:
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Drawing.EnableUnixSupport" Value="true" />
</ItemGroup>
4. Now you are ready to run your project with dotnet run