Skip to content

Latest commit

 

History

History
114 lines (71 loc) · 5.64 KB

packaging-installation.md

File metadata and controls

114 lines (71 loc) · 5.64 KB

.NET Core Packaging and Installation

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.

Using the SDK directly (install per-user)

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.

Installing the SDK globally

If you want to install the SDK globally (and not per user), here are some suggestions.

  1. 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/.

  2. Create a symlink from /usr/local/bin/dotnet (or an equivalent location available in $PATH) to the dotnet 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.

  3. 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

  4. Define DOTNET_ROOT and update PATH 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 (including dash) and bash. 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 a dotnet tool install.

Creating a Linux distribution package

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:

  1. Extract the tarball to the distribution appropriate location such as /usr/lib64/dotnet/, /usr/lib/dotnet/, or /usr/lib/x86_64-linux-gnu/dotnet/.

  2. Create a symlink from /usr/bin/dotnet (or equivalent) to the dotnet 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.

  3. 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.

  4. Define DOTNET_ROOT and update PATH 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 (including dash) and bash. 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 a dotnet tool install.

There are other optional things you can do:

Resources and references