[玩转系统] 在 Rocky Linux 8|AlmaLinux 8|RHEL 8 上安装 .NET Core 6.0
作者:精品下载站 日期:2024-12-14 12:22:54 浏览:11 分类:玩电脑
在 Rocky Linux 8|AlmaLinux 8|RHEL 8 上安装 .NET Core 6.0
在本文中,我们将在 Rocky Linux 8|AlmaLinux 8|RHEL 8 上安装 .NET Core 6.0。.NET 是一个由编程语言、工具和库组成的开发人员平台,可帮助开发人员构建不同类型的应用程序。 ASP.NET 框架通过工具和库扩展了 .NET 开发人员平台,使 Web 应用程序的构建变得顺利、轻松。截至本文撰写时,.NET Core 的最新版本是 6.0,这是一个 LTS 版本。
.NET 6.0 LTS 版本可在 Windows、Linux 和 macOS 操作系统上下载。该包包括 .NET 运行时和 ASP.NET Core 运行时。 IIS 用户可以单独安装 ASP.NET Core 模块,无需安装 .NET Runtime。
以下发行版可用于 Linux:
- .NET SDK:包括用于构建和测试应用程序的工具,并包括随后的运行时发行版。
- .NET 运行时:包括 .NET 运行时和库,支持运行控制台应用程序。
- ASP.NET Core 运行时:包括 .NET 和 ASP.NET Core 运行时,支持运行控制台和 Web 应用程序。
在 Rocky Linux 8|AlmaLinux 8|RHEL 8 上安装 .NET Core 6.0
作为开发人员,您可以安装 .NET SDK 来开发和构建应用程序。一旦应用程序经过测试,就需要其中一个运行时包(例如 ASP.NET Core)来专门运行应用程序。
安装 Rocky Linux 8|AlmaLinux 8|RHEL 8 上的 .NET SDK 6
包含的运行时间是:
- .NET运行时
- ASP.NET Core 运行时
- .NET 桌面运行时
我们将使用 dotnet-install 脚本在 Linux 系统上自动安装 SDK 和运行时。该脚本默认安装最新的 SDK 长期支持 (LTS),截至更新本文时为 6.0 LTS。
安装wget或curl下载器:
sudo dnf -y install wget curl
在本地下载 .NET 安装程序脚本:
#Using curl
curl -sLO https://dot.net/v1/dotnet-install.sh
#Using wget
wget https://dot.net/v1/dotnet-install.sh
给出脚本执行位:
chmod +x dotnet-install.sh
我们将使用的脚本选项:
- -c,-channel:从指定通道下载,默认为
LTS
。
运行以下命令将安装.NET SDK 6.0。
$ ./dotnet-install.sh -c 6.0
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.101/dotnet-sdk-6.0.101-linux-x64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.101/dotnet-sdk-6.0.101-linux-x64.tar.gz
dotnet-install: Adding to current process PATH: `/home/rocky/.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.
要安装当前的 LTS 版本,请使用:
$ ./dotnet-install.sh -c Current
要安装 .NET Runtime 而不是 SDK,请使用 -runtime 参数。
$ ./dotnet-install.sh -c Current --runtime aspnetcore
将 .NET 二进制文件目录添加到您的 PATH
将 ~/.dotnet/
添加到您的 PATH 环境变量中:
echo 'export PATH=$PATH:~/.dotnet/' | tee -a ~/.bashrc
确认其有效:
$ source ~/.bashrc
$ echo $PATH
$ echo $PATH
/home/rocky/.local/bin:/home/rocky/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/rocky/.dotnet/
尝试运行 dotnet 命令来检查版本:
$ dotnet --version
6.0.101
创建 hello world 测试
$ dotnet new console -o helloworld
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.101
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
The template "Console App" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on /home/rocky/helloworld/helloworld.csproj...
Determining projects to restore...
Restored /home/rocky/helloworld/helloworld.csproj (in 97 ms).
Restore succeeded.
运行应用程序
$ cd helloworld
$ dotnet run
Hello, World!
为 .NET CLI 启用 TAB 自动补全
.NET CLI 的 Tab 补全是通过在 shell 中键入 dotnet 命令然后按 TAB 键来触发的。如下所示为您的 Shell 设置。
重击
要向 .NET CLI 的 bash shell 添加制表符补全功能,请将以下代码添加到您的 .bashrc
文件中:
$ vim ~/.bashrc
# bash parameter completion for the dotnet CLI
_dotnet_bash_complete()
{
local word=${COMP_WORDS[COMP_CWORD]}
local completions
completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
if [ $? -ne 0 ]; then
completions=""
fi
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}
complete -f -F _dotnet_bash_complete dotnet
兹什
要向 .NET CLI 的 zsh shell 添加 Tab 键补全功能,请将以下代码添加到您的 .zshrc
文件中:
$ vim ~/.zshrc
# zsh parameter completion for the dotnet CLI
_dotnet_zsh_complete()
{
local completions=("$(dotnet complete "$words")")
reply=( "${(ps:\n:)completions}" )
}
compctl -K _dotnet_zsh_complete dotnet
Tab 补全用法示例:
结论
.NET 是一个跨平台开发人员平台,旨在帮助您构建应用程序。 .NET 应用程序可以使用 C#、F# 或 Visual Basic 编程语言编写。在本文中,我们已经能够在 Rocky Linux 8|AlmaLinux 8|RHEL 8 Linux 系统上安装 .NET Core 6.0。从此时起,您可以开始使用 .NET 构建适用于移动、Web、云、桌面、机器学习、游戏开发、物联网、微服务和许多其他平台的应用程序。
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[影视] 黑道中人 Alto Knights(2025)剧情 犯罪 历史 电影
[古装剧] [七侠五义][全75集][WEB-MP4/76G][国语无字][1080P][焦恩俊经典]
[实用软件] 虚拟手机号 电话 验证码 注册
[电视剧] 安眠书店/你 第五季 You Season 5 (2025) 【全10集】
[电视剧] 棋士(2025) 4K 1080P【全22集】悬疑 犯罪 王宝强 陈明昊
[软件合集] 25年6月5日 精选软件22个
[软件合集] 25年6月4日 精选软件36个
[短剧] 2025年06月04日 精选+付费短剧推荐33部
[短剧] 2025年06月03日 精选+付费短剧推荐25部
[软件合集] 25年6月3日 精选软件44个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[实用软件] 虚拟手机号 电话 验证码 注册
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[影视] 内地绝版高清录像带 [mpg]
[书籍] 古今奇书禁书三教九流资料大合集 猎奇必备珍藏资源PDF版 1.14G
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag