This document helps you install or package a .NET Core SDK built using source-build.
The SDK built by source-build is generally not portable. That means it will work on the same operating system where it was built. It will not work on older operating systems. It may work on newer operating systems.
The built SDK is generally located at artifacts/${ARCHITECTURE}/Release/dotnet-sdk-${SDK_VERSION}-${RUNTIME_ID}.tar.gz
.
To use the SDK directly, unpack the SDK to any directory and then use the dotnet
executable from it.
You can find more details on how to manually install an SDK from a tarball at manually installing an SDK. The same steps listed should work for all Linux distributions where bash
(or sh
) is the default shell.
If you want to install the SDK globally (and not per user), here are some suggestions.
-
Extract the tarball to a distribution-appropriate location such as
/usr/local/lib64/dotnet/
,/usr/local/lib/dotnet/
, or/usr/local/lib/x86_64-linux-gnu/dotnet/
. -
Create a symlink from
/usr/local/bin/dotnet
(or an equivalent location available in$PATH
) to thedotnet
binary in the SDK that you installed in the previous step. For example:ln -s /usr/local/lib64/dotnet/dotnet /usr/local/bin/dotnet
Now users can simply run
dotnet
and it will work. -
Create an
/etc/dotnet/install_location
file and add the path of the SDK directory in there. The file should contain a single line like this:/usr/local/lib64/dotnet/
This file is used by .NET Core to find the SDK/Runtime location
-
Define
DOTNET_ROOT
and updatePATH
by saving the following as/etc/profile.d/dotnet-local.sh
(or equivalent)# Set location for AppHost lookup [ -z "$DOTNET_ROOT" ] && export DOTNET_ROOT=/usr/local/lib64/dotnet # Add dotnet tools directory to PATH DOTNET_TOOLS_PATH="$HOME/.dotnet/tools" case "$PATH" in *"$DOTNET_TOOLS_PATH"* ) true ;; * ) PATH="$PATH:$DOTNET_TOOLS_PATH" ;; esac
Make sure to adjust the paths to match what you used on your system.
This snippet should work in
sh
(includingdash
) andbash
. You may need to adapt it, or use something entirely different, for other shells.This allows apphost-lookup to work via
DOTNET_ROOT
and allows users to easily use dotnet tools directly after adotnet tool install
.
If you want to create a Linux distribution package (rpm
, deb
) out of the source-build SDK here are some suggestions.
See .NET Core distribution packaging for information on suggested packages, subpackages, name and contents.
This is the minimal amount of content you need to package up:
-
Extract the tarball to the distribution appropriate location such as
/usr/lib64/dotnet/
,/usr/lib/dotnet/
, or/usr/lib/x86_64-linux-gnu/dotnet/
. -
Create a symlink from
/usr/bin/dotnet
(or equivalent) to thedotnet
binary in the SDK that you installed in the previous step. For example:ln -s /usr/lib64/dotnet/dotnet /usr/bin/dotnet
Now users can simply run
dotnet
and it will work. -
Create an
/etc/dotnet/install_location
file and add the path of the SDK directory in there. The file should contain a single line like this:/usr/lib64/dotnet
This file is used by .NET Core to find the SDK/Runtime location.
-
Define
DOTNET_ROOT
and updatePATH
by saving the following as/etc/profile.d/dotnet.sh
(or equivalent)# Set location for AppHost lookup [ -z "$DOTNET_ROOT" ] && export DOTNET_ROOT=/usr/lib64/dotnet # Add dotnet tools directory to PATH DOTNET_TOOLS_PATH="$HOME/.dotnet/tools" case "$PATH" in *"$DOTNET_TOOLS_PATH"* ) true ;; * ) PATH="$PATH:$DOTNET_TOOLS_PATH" ;; esac
Make sure to adjust the paths to match what the distribution policies.
This snippet should work in
sh
(includingdash
) andbash
. You may need to adapt it, or use something entirely different, for other shells.This allows apphost-lookup to work via
DOTNET_ROOT
and allows users to easily use dotnet tools directly after adotnet tool install
.
There are other optional things you can do:
-
.NET Core source repositories include man pages. You can search for them and package them up:
find -iname '*.1' -exec cp {} /usr/share/man/man1/ \;
-
.NET Core includes bash-completion and zsh-completion scripts. The copies in the source code you used to build the SDK should be the latest version. See how to enable tab completion for .NET Core cli for more information.