이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 1. Using .NET Core 3.0 on Red Hat Enterprise Linux


This Getting Started Guide describes how to install .NET Core 3.0 on Red Hat Enterprise Linux (RHEL). See Red Hat Enterprise Linux documentation for more information about RHEL 7.

1.1. Install and Register Red Hat Enterprise Linux

  1. Install RHEL 7 using one of the following images:

  2. Use the following command to register the system.

    $ sudo subscription-manager register

    You can also register the system by following the appropriate steps in Registering and Unregistering a System in the Red Hat Subscription Management document.

  3. Display a list of all subscriptions that are available for your system and identify the pool ID for the subscription.

    $ sudo subscription-manager list --available

    This command displays the subscription name, unique identifier, expiration date, and other details related to it. The pool ID is listed on a line beginning with Pool ID.

  4. Attach the subscription that provides access to the dotNET on RHEL repository. Use the pool ID you identified in the previous step.

    $ sudo subscription-manager attach --pool=<appropriate pool ID from the subscription>
  5. Enable the .NET Core channel for Red Hat Enterprise 7 Server, Red Hat Enterprise 7 Workstation, or HPC Compute Node with one of the following commands, respectively.

    $ sudo subscription-manager repos --enable=rhel-7-server-dotnet-rpms
    $ sudo subscription-manager repos --enable=rhel-7-workstation-dotnet-rpms
    $ sudo subscription-manager repos --enable=rhel-7-hpc-node-dotnet-rpms
  6. Verify the list of subscriptions attached to your system.

    $ sudo subscription-manager list --consumed
  7. Install the scl tool.

    $ sudo yum install scl-utils

1.2. Install .NET Core

  1. Install .NET Core 3.0 and all of its dependencies.

    $ sudo yum install rh-dotnet30 -y
  2. Enable the rh-dotnet30 Software Collection environment so you can run dotnet commands in the bash shell.

    This procedure installs the .NET Core 3.0 runtime with the latest 3.0 SDK. When a newer SDK becomes available, it automatically installs as a package update.

    $ scl enable rh-dotnet30 bash

    This command does not persist; it creates a new shell, and the dotnet command is only available within that shell. If you log out, use another shell, or open up a new terminal, the dotnet command is no longer enabled.

    Warning

    Red Hat does not recommend permanently enabling rh-dotnet30 because it may affect other programs. For example, rh-dotnet30 includes a version of libcurl that differs from the base RHEL version. This may lead to issues in programs that do not expect a different version of libcurl. If you want to enable rh-dotnet permanently, add the following line to your ~/.bashrc file.

    source scl_source enable rh-dotnet30

  3. Run the following command to verify the installation succeeded.

    $ dotnet --info
    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100
     Commit:    xxxxxxxxxx
    
    Runtime Environment:
     OS Name:     rhel
     OS Version:  7
     OS Platform: Linux
     RID:         rhel.7-x64
     Base Path:   /opt/rh/rh-dotnet30/root/usr/lib64/dotnet/sdk/3.0.100/
    
    Host (useful for support):
      Version: 3.0.0
      Commit:  xxxxxxxxxx
    
    .NET Core SDKs installed:
      3.0.100 [/opt/rh/rh-dotnet30/root/usr/lib64/dotnet/sdk]
    
    .... omitted

1.3. Create an Application

  1. Create a new Console application in a directory called hello-world.

    $ dotnet new console -o hello-world
      The template "Console Application" was created successfully.
    
      Processing post-creation actions...
      Running 'dotnet restore' on hello-world/hello-world.csproj...
      Restore completed in 87.21 ms for /home/<USER>/hello-world/hello-world.csproj.
    
      Restore succeeded.
  2. Run the project.

    $ cd hello-world
    $ dotnet run
    Hello World!

1.4. Publish Applications

The .NET Core 3.0 applications can be published to use a shared system-wide version of .NET Core or to include .NET Core. These two deployment types are called framework-dependent deployment (FDD) and self-contained deployment (SCD), respectively.

For RHEL, we recommend publishing by FDD. This method ensures the application is using an up-to-date version of .NET Core, built by Red Hat, that includes a specific set of native dependencies. These native libraries are part of the rh-dotnet30 Software Collection. On the other hand, SCD uses a runtime built by Microsoft. Running applications outside the rh-dotnet30 Software Collection may cause issues due to the unavailability of native libraries.

  1. Use the following command to publish a framework-dependent application.

    $ dotnet publish -f netcoreapp3.0 -c Release
  2. Optional: If the application is only for RHEL, trim out the dependencies needed for other platforms with these commands.

    $ dotnet restore -r rhel.7-x64
    $ dotnet publish -f netcoreapp3.0 -c Release -r rhel.7-x64 --self-contained false
  3. Enable the Software Collection and pass the application name to run the application on a RHEL system.

    $ scl enable rh-dotnet30 -- dotnet <app>.dll
  4. This command can be added to a script that is published with the application. Add the following script to your project and update the APP variable.

    #!/bin/bash
    
    APP=<app>
    SCL=rh-dotnet30
    DIR="$(dirname "$(readlink -f "$0")")"
    
    scl enable $SCL -- "$DIR/$APP" "$@"
  5. To include the script when publishing, add this ItemGroup to the csproj file.

    <ItemGroup>
        <None Update="<scriptname>" Condition="'$(RuntimeIdentifier)' == 'rhel.7-x64' and '$(SelfContained)' == 'false'" CopyToPublishDirectory="PreserveNewest" />
    </ItemGroup>

1.5. Run Applications on Linux Containers

This section shows how to use the dotnet/dotnet-30-runtime-rhel7 image to run a precompiled application inside a Linux container.

  1. Create a new mvc project in a directory named mvc_runtime_example.

    $ dotnet new mvc -o mvc_runtime_example
    $ cd mvc_runtime_example
  2. Publish the project.

    $ dotnet publish -f netcoreapp3.0 -c Release
  3. Create the Dockerfile.

    $ cat > Dockerfile <<EOF
    FROM registry.redhat.io/dotnet/dotnet-30-runtime-rhel7
    
    ADD bin/Release/netcoreapp3.0/publish/ .
    
    CMD ["dotnet", "mvc_runtime_example.dll"]
    EOF
  4. Build your image.

    $ podman build -t dotnet-30-runtime-example .
    Note

    If you get an error containing the message unable to retrieve auth token: invalid username/password, you need to provide credentials for the registry.redhat.io server. Use the command $ podman login registry.redhat.io to log in. Your credentials are typically the same as those used for the Red Hat Customer Portal.

  5. Run your image.

    $ podman run -d -p8080:8080 dotnet-30-runtime-example
  6. View the result in a browser: http://127.0.0.1:8080.

Report a bug

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동