適用於.NET Core macOS 上的必要條件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

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

  • macOS 10.12"利也"和更新版本macOS 10.12 "Sierra" and later versions

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

.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.

增加開啟檔案上限Increase the maximum open file limit

MacOS 的預設開啟的檔案限制可能無法完全針對.NET 核心工作負載,例如還原專案或執行單元測試。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"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string>2048</string>
      <string>4096</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>
  1. 在終端機視窗中,執行下列命令:In a terminal window, run the following command:
echo 'ulimit -n 2048' | sudo tee -a /etc/profile
  1. 重新啟動才能套用這些設定 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