Mac Catalina Brew



  1. Mac Catalina Brew
  2. Brew Macos Catalina
  3. Mac Catalina Install Brew
  4. Mac Catalina Brew Update

Nevertheless, I felt that the advice boiled down to: 'use whichever gpg binary is the latest available on brew'. So I tried: brew update brew upgrade git brew install gpg # the following are suggestions from brew's Caveats, to make `/usr/local/bin/gpg` # point to the brew binary: rm '/usr/local/bin/gpg' brew link -overwrite gnupg2. If you have a newer Mac, it likely uses a speedy solid-state drive to store files, apps, music, videos, and a lot of other important stuff. But there’s one thing you may not know about SSDs.

-->

在本文中,你将了解如何在 macOS 上安装 .NET。In this article, you'll learn how to install .NET on macOS..NET 由运行时和 SDK 组成。.NET is made up of the runtime and the SDK.运行时用于运行 .NET 应用,应用可能包含也可能不包含它。The runtime is used to run a .NET app and may or may not be included with the app.SDK 用于创建 .NET 应用和库。The SDK is used to create .NET apps and libraries..NET 运行时始终随 SDK 一起安装。The .NET runtime is always installed with the SDK.

最新版本的 .NET 是 5.0。The latest version of .NET is 5.0.

支持的版本Supported releases

下表列出了当前支持的 .NET 版本以及支持它们的 macOS 版本。The following table is a list of currently supported .NET releases and the versions of macOS they're supported on.这些版本仍受支持,除非任一 .NET 版本达到支持终止日期。These versions remain supported either the version of .NET reaches end-of-support.

  • ✔️ 指示 .NET Core 版本仍受支持。A ✔️ indicates that the version of .NET Core is still supported.
  • ❌ 指示 .NET Core 版本不受支持。A ❌ indicates that the version of .NET Core isn't supported.
操作系统Operating System.NET Core 2.1.NET Core 2.1.NET Core 3.1.NET Core 3.1.NET 5.0.NET 5.0
macOS 11.0“Big Sur”macOS 11.0 'Big Sur'✔️ 2.1(发行说明)✔️ 2.1 (Release notes)✔️ 3.1(发行说明)✔️ 3.1 (Release notes)✔️ 5.0(发行说明)✔️ 5.0 (Release notes)
macOS 10.15“Catalina”macOS 10.15 'Catalina'✔️ 2.1(发行说明)✔️ 2.1 (Release notes)✔️ 3.1(发行说明)✔️ 3.1 (Release notes)✔️ 5.0(发行说明)✔️ 5.0 (Release notes)
macOS 10.14“Mojave”macOS 10.14 'Mojave'✔️ 2.1(发行说明)✔️ 2.1 (Release notes)✔️ 3.1(发行说明)✔️ 3.1 (Release notes)✔️ 5.0(发行说明)✔️ 5.0 (Release notes)
macOS 10.13“High Sierra”macOS 10.13 'High Sierra'✔️ 2.1(发行说明)✔️ 2.1 (Release notes)✔️ 3.1(发行说明)✔️ 3.1 (Release notes)✔️ 5.0(发行说明)✔️ 5.0 (Release notes)
macOS 10.12“Sierra”macOS 10.12 'Sierra'✔️ 2.1(发行说明)✔️ 2.1 (Release notes)❌ 3.1(发行说明)❌ 3.1 (Release notes)❌ 5.0(发行说明)❌ 5.0 (Release notes)

不支持的版本Unsupported releases

以下 .NET 版本 ❌ 不再受到支持。The following versions of .NET are ❌ no longer supported.这些版本的下载仍保持发布状态:The downloads for these still remain published:

  • 3.0(发行说明)3.0 (Release notes)
  • 2.2(发行说明)2.2 (Release notes)
  • 2.0(发行说明)2.0 (Release notes)

运行时信息Runtime information

运行时用于运行使用 .NET 创建的应用。The runtime is used to run apps created with .NET.应用作者发布应用时,可以在其应用中包含运行时。When an app author publishes an app, they can include the runtime with their app.如果作者未包含运行时,则由用户安装运行时。If they don't include the runtime, it's up to the user to install the runtime.

macOS 上可以安装两种不同的运行时:There are two different runtimes you can install on macOS:

  • ASP.NET Core 运行时ASP.NET Core runtime
    运行 ASP.NET Core 应用。Runs ASP.NET Core apps.包括 .NET 运行时。Includes the .NET runtime.

  • .NET 运行时.NET runtime
    此运行时是最简单的运行时,不包括任何其他运行时。This runtime is the simplest runtime and doesn't include any other runtime.强烈建议安装 ASP.NET Core 运行时,以最大限度地提升与 .NET 应用的兼容性。It's highly recommended that you install ASP.NET Core runtime for the best compatibility with .NET apps.

SDK 信息SDK information

SDK 用于生成和发布 .NET 应用和库。The SDK is used to build and publish .NET apps and libraries.安装 SDK 会包含两个运行时:ASP.NET Core 和 .NET。Installing the SDK includes both runtimes: ASP.NET Core and .NET.

依赖项Dependencies

以下 macOS 版本支持 .NET:.NET is supported on the following macOS releases:

备注

+ 表示最低版本。A + symbol represents the minimum version.

.NET Core 版本.NET Core VersionmacOSmacOS体系结构Architectures详细信息More information
5.05.0High Sierra (10.13+)High Sierra (10.13+)X64x64详细信息More information
3.13.1High Sierra (10.13+)High Sierra (10.13+)X64x64详细信息More information
3.03.0High Sierra (10.13+)High Sierra (10.13+)X64x64详细信息More information
2.22.2Sierra (10.12+)Sierra (10.12+)X64x64详细信息More information
2.12.1Sierra (10.12+)Sierra (10.12+)X64x64详细信息More information

自 macOS Catalina(版本10.15)开始,所有在 2019 年 6 月 1 日之后生成并使用开发者 ID 扩散的软件都必须经过公证。Beginning with macOS Catalina (version 10.15), all software built after June 1, 2019 that is distributed with Developer ID, must be notarized.此要求适用于 .NET 运行时、.NET SDK 以及使用 .NET 创建的软件。This requirement applies to the .NET runtime, .NET SDK, and software created with .NET.

自 2020 年 2 月 18 日起,.NET 5.0 和 .NET Core 3.1、3.0 和 2.1 的运行时和 SDK 安装程序都已经过公证。The runtime and SDK installers for .NET 5.0 and .NET Core 3.1, 3.0, and 2.1, have been notarized since February 18, 2020.以前发布的版本没有经过公证。Prior released versions aren't notarized.如果运行未经过公证的应用,将看到类似于下图的错误:If you run a non-notarized app, you'll see an error similar to the following image:

若要详细了解强制执行的公证要求对 .NET 和 .NET 应用的影响,请参阅处理 macOS Catalina 公证。For more information about how enforced-notarization affects .NET (and your .NET apps), see Working with macOS Catalina Notarization.

libgdipluslibgdiplus

Mac catalina brew recipe

使用 System.Drawing.Common 程序集的 .NET 应用程序要求安装 libgdiplus。.NET applications that use the System.Drawing.Common assembly require libgdiplus to be installed.

获取 libgdiplus 的一个简单方法是使用适用于 macOS 的 Homebrew (“brew”) 包。An easy way to obtain libgdiplus is by using the Homebrew ('brew') package manager for macOS.在安装 brew 后,通过在终端(命令)提示符处执行以下命令来安装 libgdiplus:After installing brew, install libgdiplus by executing the following commands at a Terminal (command) prompt:

使用安装程序安装Install with an installer

macOS 具有独立的安装程序,可用于安装 .NET 5.0 SDK:macOS has standalone installers that can be used to install the .NET 5.0 SDK:

下载并手动安装Download and manually install

除了使用适用于 .NET 的 macOS 安装程序,还可以下载并手动安装 SDK 和运行时。As an alternative to the macOS installers for .NET, you can download and manually install the SDK and runtime.手动安装通常作为持续集成测试的一部分执行。Manual install is usually performed as part of continuous integration testing.对于开发人员或用户,一般使用安装程序会更好。For a developer or user, it's generally better to use an installer.

如果安装 .NET SDK,则无需安装相应的运行时。If you install .NET SDK, you don't need to install the corresponding runtime.首先,从以下站点之一下载 SDK 或运行时的二进制版本:First, download a binary release for either the SDK or the runtime from one of the following sites:

  • ✔️ .NET 5.0 下载✔️ .NET 5.0 downloads
  • ✔️ .NET Core 3.1 下载✔️ .NET Core 3.1 downloads
  • ✔️ .NET Core 2.1 下载✔️ .NET Core 2.1 downloads

接下来,提取已下载的文件并使用 export 命令设置 .NET 使用的变量,然后确保 .NET 在 PATH 中。Next, extract the downloaded file and use the export command to set variables used by .NET and then ensure .NET is in PATH.

若要提取运行时并使 .NET CLI 命令可用于终端,请先下载 .NET 二进制版本。To extract the runtime and make the .NET CLI commands available at the terminal, first download a .NET binary release.然后,打开终端并从保存文件的目录运行以下命令。Then, open a terminal and run the following commands from the directory where the file was saved.根据下载内容,存档文件名称可能不同。The archive file name may be different depending on what you downloaded.

使用以下命令提取已下载的运行时或 SDK。Use the following commands to extract the runtime or SDK that you downloaded.请记得将 DOTNET_FILE 值更改为你的文件名:Remember to change the DOTNET_FILE value to your file name:

提示

前面的 export 命令只会使 .NET CLI 命令对运行它的终端会话可用。The preceding export commands only make the .NET CLI commands available for the terminal session in which it was run.

你可以编辑 shell 配置文件,永久地添加这些命令。You can edit your shell profile to permanently add the commands.Linux 提供了许多不同的 shell,每个都有不同的配置文件。There are a number of different shells available for Linux and each has a different profile.例如:For example:

  • Bash Shell:~/.bash_profile、~/.bashrcBash Shell: ~/.bash_profile, ~/.bashrc
  • Korn Shell:~/.kshrc 或 .profileKorn Shell: ~/.kshrc or .profile
  • Z Shell:~/.zshrc 或 .zprofileZ Shell: ~/.zshrc or .zprofile

为 shell 编辑相应的源文件,并将 :$HOME/dotnet 添加到现有 PATH 语句的末尾。Edit the appropriate source file for your shell and add :$HOME/dotnet to the end of the existing PATH statement.如果不包含 PATH 语句,则使用 export PATH=$PATH:$HOME/dotnet 添加新行。If no PATH statement is included, add a new line with export PATH=$PATH:$HOME/dotnet.

另外,将 export DOTNET_ROOT=$HOME/dotnet 添加至文件的末尾。Also, add export DOTNET_ROOT=$HOME/dotnet to the end of the file.

使用此方法可以将不同的版本安装到不同的位置,并明确选择应用程序要使用的对应版本。This approach lets you install different versions into separate locations and choose explicitly which one to use by which application.

使用 Visual Studio for Mac 安装Install with Visual Studio for Mac

选定 .NET 工作负载后,可使用 Visual Studio for Mac 安装 .NET SDK。Visual Studio for Mac installs the .NET SDK when the .NET workload is selected.若要开始在 macOS 上进行 .NET 开发,请参阅安装 Visual Studio 2019 for Mac。To get started with .NET development on macOS, see Install Visual Studio 2019 for Mac.

Mac Catalina Brew

.NET SDK 版本.NET SDK versionVisual Studio 版本Visual Studio version
5.05.0Visual Studio 2019 for Mac 版本 8.8 或更高版本。Visual Studio 2019 for Mac version 8.8 or higher.
3.13.1Visual Studio 2019 for Mac 版本 8.4 或更高版本。Visual Studio 2019 for Mac version 8.4 or higher.
2.12.1Visual Studio 2019 for Mac 版本 8.0 或更高版本。Visual Studio 2019 for Mac version 8.0 or higher.

随 Visual Studio Code 一起安装Install alongside Visual Studio Code

Visual Studio Code 是一个功能强大的轻量级源代码编辑器,可在桌面上运行。Visual Studio Code is a powerful and lightweight source code editor that runs on your desktop.Visual Studio Code 适用于 Windows、macOS 和 Linux。Visual Studio Code is available for Windows, macOS, and Linux.

虽然 Visual Studio Code 不像 Visual Studio 一样附带自动的 .NET 安装程序,但添加 .NET 支持非常简单。While Visual Studio Code doesn't come with an automated .NET installer like Visual Studio does, adding .NET support is simple.

  1. 下载并安装 Visual Studio Code。Download and install Visual Studio Code.
  2. 下载并安装 .NET SDK。Download and install the .NET SDK.
  3. 从 Visual Studio Code 市场安装 C# 扩展。Install the C# extension from the Visual Studio Code marketplace.

Brew Macos Catalina

使用 Bash 自动化安装Install with bash automation

dotnet-install 脚本用于运行时的自动化和非管理员安装。The dotnet-install scripts are used for automation and non-admin installs of the runtime.可从 dotnet-install 脚本引用页下载该脚本。You can download the script from the dotnet-install script reference page.

Mac Catalina Install Brew

此脚本默认安装最新的长期支持 (LTS) 版本,即 .NET Core 3.1。The script defaults to installing the latest long term support (LTS) version, which is .NET Core 3.1.可通过指定 current 开关以选择特定版本。You can choose a specific release by specifying the current switch.包括 runtime 开关以安装运行时。Include the runtime switch to install a runtime.否则,该脚本安装 SDK。Otherwise, the script installs the SDK.

Mac Catalina Brew Update

备注

可以使用前面的命令安装 ASP.NET Core 运行时,以实现最大的兼容性。The previous command installs the ASP.NET Core runtime for maximum compatability.ASP.NET Core 运行时还包括标准 .NET 运行时。The ASP.NET Core runtime also includes the standard .NET runtime.

DockerDocker

容器提供了一种将应用程序与主机系统的其余部分隔离的轻量级方法。Containers provide a lightweight way to isolate your application from the rest of the host system.同一计算机上的容器只共享内核,并使用为应用程序提供的资源。Containers on the same machine share just the kernel and use resources given to your application.

.NET 可在 Docker 容器中运行。.NET can run in a Docker container.官方 .NET Docker 映像发布到 Microsoft 容器注册表 (MCR),用户可在 Microsoft.NET Core Docker Hub 存储库中找到这些映像。Official .NET Docker images are published to the Microsoft Container Registry (MCR) and are discoverable at the Microsoft .NET Core Docker Hub repository.每个存储库包含 .NET(SDK 或运行时)和可以使用的操作系统的不同组合的映像。Each repository contains images for different combinations of the .NET (SDK or Runtime) and OS that you can use.

Microsoft 提供适合特定场景的映像。Microsoft provides images that are tailored for specific scenarios.例如,ASP.NET Core 存储库提供针对在生产环境中运行 ASP.NET Core 应用生成的映像。For example, the ASP.NET Core repository provides images that are built for running ASP.NET Core apps in production.

有关在 Docker 容器中使用 .NET Core 的详细信息,请参阅 .NET 和 Docker 简介和示例。For more information about using .NET Core in a Docker container, see Introduction to .NET and Docker and Samples.

后续步骤Next steps

  • 如何检查是否已安装 .NET Core。How to check if .NET Core is already installed.
  • 处理 macOS Catalina 公证。Working with macOS Catalina notarization.
  • 教程:开始使用 macOS。Tutorial: Get started on macOS.
  • 教程:使用 Visual Studio Code 创建一个新应用。Tutorial: Create a new app with Visual Studio Code.
  • 教程:使 .NET Core 应用容器化。Tutorial: Containerize a .NET Core app.