macOS 上 .NET Core 的先決條件Prerequisites for .NET Core on macOS

本文章說明在 macOS 電腦上開發、部署和執行 .NET Core 應用程式,所需之支援的 macOS 版本和 .NET Core 的相依性。This article shows you the supported macOS versions and .NET Core dependencies that you need to develop, deploy, and run .NET Core applications on macOS machines. 下述支援的 OS 版本與相依性適用於三種在 Mac 上開發 .NET Core 應用程式的方式:透過命令列搭配您慣用的編輯器Visual Studio Code (英文),以及 Visual Studio for MacThe supported OS versions and dependencies that follow apply to the three ways of developing .NET Core apps on a Mac: via the command-line with your favorite editor, Visual Studio Code, and Visual Studio for Mac.

支援的 macOS 版本Supported macOS versions

下列 macOS 版本支援 .NET Core 2.x:.NET Core 2.x is supported on the following versions of macOS:

  • macOS 10.12 "Sierra" (含) 以上版本macOS 10.12 "Sierra" and later versions

如需 .NET Core 2.1 和 .NET Core 2.2 支援的作業系統完整清單、發行版本與版本、不支援的 OS 版本,以及生命週期原則連結,請參閱 .NET Core 2.1 支援的 OS 版本.NET Core 2.2 支援的 OS 版本See .NET Core 2.1 Supported OS Versions and .NET Core 2.2 Supported OS Versions for the complete list of .NET Core 2.1 and .NET Core 2.2 supported operating systems, distributions and versions, out of support OS versions, and lifecycle policy links.

如需下載連結和詳細資訊,請參閱 .NET Core 2.2 下載.NET Core 2.1 下載For download links and more information, see .NET Core 2.2 downloads or .NET Core 2.1 downloads.

.NET Core 的相依性.NET Core dependencies

請從 .NET 下載 (英文) 下載並安裝 .NET Core SDK。Download and install the .NET Core SDK from .NET Downloads. 如果您在 macOS 上有安裝的問題,請參閱已安裝版本的已知問題主題。If you have problems with the installation on macOS, consult the Known issues topic for the version you have installed.

增加開啟的檔案上限 (.NET Core SDK 2.0.2 之前的 .NET Core 版本)Increase the maximum open file limit (.NET Core versions before .NET Core SDK 2.0.2)

在較舊的 .NET Core 版本中 (.NET Core SDK 2.0.2 之前),macOS 的預設開啟檔案限制可能對一些 .NET Core 工作負載而言不足,例如還原專案或執行單元測試。In older .NET Core versions (before .NET Core SDK 2.0.2), the default open file limit on macOS may not be sufficient for some .NET Core workloads, such as restoring projects or running unit tests.

您可以遵循下列步驟來增加此限制:You can increase this limit by following these steps:

  1. 使用文字編輯器建立新檔案 /Library/LaunchDaemons/limit.maxfiles.plist,並儲存含此內容的檔案:Using a text editor, create a new file /Library/LaunchDaemons/limit.maxfiles.plist, and save the file with this content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
    <plist version="1.0">
  2. 在終端機視窗中,執行下列命令:In a terminal window, run the following command:

    echo 'ulimit -n 2048' | sudo tee -a /etc/profile
  3. 重新啟動 Mac,以套用這些設定。Reboot your Mac to apply these settings.

Visual Studio for MacVisual Studio for Mac

您可以使用任何編輯器來開發使用 .NET Core SDK 的 .NET Core 應用程式。You can use any editor to develop .NET Core applications using the .NET Core SDK. 不過,如果您想要在整合式開發環境中於 Mac 上開發 .NET Core 應用程式,則可以使用 Visual Studio for MacHowever, if you want to develop .NET Core applications on a Mac in an integrated development environment, you can use Visual Studio for Mac.

使用 Visual Studio for Mac 在 macOS 上進行 .NET Core 開發需具備︰.NET Core development on macOS with Visual Studio for Mac requires:

  • 支援的 macOS 作業系統版本A supported version of the macOS operating system
  • OpenSSL (僅限 .NET Core 1.x;.NET Core 2.x 會使用 macOS 中原生提供的安全性服務)OpenSSL (.NET Core 1.x only; .NET Core 2.x uses security services available natively in macOS)
  • 適用於 Mac 的 .NET Core SDK.NET Core SDK for Mac
  • Visual Studio for MacVisual Studio for Mac