Connect with us

AWS

How to install .Net 6 in Amazon Linux 2

Enable EPEL

Reference: Enable the EPEL repository for EC2 instances running CentOS, RHEL, or Amazon Linux

sudo amazon-linux-extras install epel -y

sudo yum-config-manager --enable epel

Install .Net

Manually install .NET on Linux – .NET | Microsoft Docs

# Download the installation sript
curl -L -o dotnet-install.sh   https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh 
# Install
./dotnet-install.sh -c Current


dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.

dotnet-install: Downloading primary link https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.100/dotnet-sdk-6.0.100-linux-x64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.100/dotnet-sdk-6.0.100-linux-x64.tar.gz
dotnet-install: Adding to current process PATH: `/home/ec2-user/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Note that the script does not resolve dependencies during installation.
dotnet-install: To check the list of dependencies, go to https://docs.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
dotnet-install: Installation finished successfully.

Include .Net in your Path

export PATH=/home/ec2-user/.dotnet:$PATH

Test .Net Installation

# Check installation

$ dotnet
Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.

Run a .Net Web Application

NodeJS is required for this project to compile React Components. You can install NodeJS following this guide: Install NodeJS


git clone https://github.com/vivasaayi/thulir.git

# Navigate to the project root
cd thulir

# Use NodeJS 16
nvm use node 16

# Note: This can be done beforehand and realeased. But for our example, we do it on the server.
# Restore Packages
dotnet restore
dotnet publish -r linux-x64 -o ~/ThulirWeb


export ASPNETCORE_URLS="http://*:80;https://*:443"

# Permissions to listen on Port 80, 443
sudo setcap cap_net_bind_service=+ep ~/ThulirWeb/Thulir.ReactUI


# Run the exe
cd ~/ThulirWeb
./Thulir.ReactUI

Continue Reading

Trending

Copyright © 2021 Rajan Panneer Selvam. Some of the content is derived from publically available information. For some of the resources I have obtained commercial licenses and you cannot use them in your projects. Before reusing any of the site content, please double-check for copyright issues. I am not responsible if you are infringing copyrights.