Windows 上 .NET Core 的必要條件Prerequisites for .NET Core on Windows

本文會說明支援的 OS 版本,以便在 Windows 上執行 .NET Core 應用程式。This article shows the supported OS versions in order to run .NET Core applications on Windows. 支援的作業系統版本和跟隨的相依性,適用於在 Windows 開發 .NET Core 應用程式的三種方式:The supported OS versions and dependencies that follow apply to the three ways of developing .NET Core apps on Windows:

此外,如果您正在使用 Visual Studio 2017 在 Windows 上進行開發,則使用 Visual Studio 2017 的必要條件一節將詳細介紹 .NET Core 開發支援的最低版本。Also, if you're developing on Windows using Visual Studio 2017, the Prerequisites with Visual Studio 2017 section goes in more detail about minimum versions supported for .NET Core development.

.NET Core 支援的 Windows 版本.NET Core supported Windows versions

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

  • Windows 7 SP1Windows 7 SP1
  • Windows 8.1Windows 8.1
  • Windows 10 年度更新 (1607 版) 或更新版本Windows 10 Anniversary Update (version 1607) or later versions
  • Windows Server 2008 R2 SP1 (完整伺服器或 Server Core)Windows Server 2008 R2 SP1 (Full Server or Server Core)
  • Windows Server 2012 SP1 (完整伺服器或 Server Core)Windows Server 2012 SP1 (Full Server or Server Core)
  • Windows Server 2012 R2 (完整伺服器或 Server Core)Windows Server 2012 R2 (Full Server or Server Core)
  • Windows Server 2016 或更新版本 (完整伺服器、Server Core 或 Nano Server)Windows Server 2016 or later versions (Full Server, Server Core, or Nano Server)

.NET core 支援的作業系統.NET Core supported operating systems

以下文件有 .NET Core 所支援每個版本作業系統的完整清單:The following articles have a complete list of .NET Core supported operating systems per version:

如需下載連結和詳細資訊,請參閱 NET 下載以下載最新版本或 .NET 下載封存 (針對舊版本)。For download links and more information, see .NET downloads to download the latest version or .NET downloads archive for older versions.

.NET Core 的相依性.NET Core dependencies

在 Windows 10 和 Windows Server 2016 之前的 Windows 版本上執行時,.NET Core 1.1 和舊版本需要 Visual C++ 可轉散發套件。.NET Core 1.1 and earlier versions require the Visual C++ Redistributable when running on Windows versions earlier than Windows 10 and Windows Server 2016. .NET Core 安裝程式會自動安裝此相依性。This dependency is automatically installed by the .NET Core installer.

必須手動安裝 Microsoft Visual C++ 2015 可轉散發套件 Update 3 的時機:Microsoft Visual C++ 2015 Redistributable Update 3 must be manually installed when:

  • 使用安裝程式指令碼安裝 .NET Core。Installing .NET Core with the installer script.
  • 部署獨立的 .NET Core 應用程式。Deploying a self-contained .NET Core application.
  • 從來源建置產品。Building the product from source.
  • 透過 .zip 檔案安裝 .NET Core。Installing .NET Core via a .zip file. 這可以包含組建/CI/CD 伺服器。This can include build/CI/CD servers.

注意

適用於 Windows 8.1 和更早版本,或 Windows Server 2012 R2 和更早版本:For Windows 8.1 and earlier versions, or Windows Server 2012 R2 and earlier versions:

請確定您的 Windows 安裝處於最新狀態,且包含 KB2999226 (機器翻譯) (可透過 Windows Update 安裝)。Make sure that your Windows installation is up-to-date and includes KB2999226, which can be installed through Windows Update. 如果沒有安裝此更新,當您啟動 .NET Core 應用程式時,將會看到如下的錯誤:The program can't start because api-ms-win-crt-runtime-1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.If you don't have this update installed, you'll see an error like the following when you launch a .NET Core application: The program can't start because api-ms-win-crt-runtime-1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

適用於 Windows 7 或 Windows Server 2008 R2:For Windows 7 or Windows Server 2008 R2:

除了 KB2999226,請確定您也已經安裝 KB2533623In addition to KB2999226, make sure you also have KB2533623 installed. 如果沒有安裝此更新,當您啟動 .NET Core 應用程式時,將會看到如下的錯誤:The library hostfxr.dll was found, but loading it from C:\<path_to_app>\hostfxr.dll failedIf you don't have this update installed, you'll see an error similar to the following when you launch a .NET Core application: The library hostfxr.dll was found, but loading it from C:\<path_to_app>\hostfxr.dll failed.

.NET Core 3.0 Preview 3 的先決條件Prerequisites for .NET Core 3.0 Preview 3

.NET Core 3.0 Preview 3 與其他版本的 .NET Core 具有相同的先決條件。.NET Core 3.0 Preview 3 has the same prerequisites as other versions of .NET Core. 不過,如果您想要使用 Visual Studio 建立 .NET Core 3.0 專案,則必須使用 Visual Studio 2019However, if you want to use Visual Studio to create .NET Core 3.0 projects, you must use the Visual Studio 2019. Visual Studio 2019 能與其他版本的 Visual Studio 並行安裝,而不會相互衝突。Visual Studio 2019 can be installed side-by-side with other versions of Visual Studio without conflict.

使用 Visual Studio 2017 的必要條件Prerequisites with Visual Studio 2017

您可以使用任何編輯器來開發使用 .NET Core SDK 的 .NET Core 應用程式。You can use any editor to develop .NET Core applications using the .NET Core SDK. Visual Studio 2017 可為 Windows 上的 .NET Core 應用程式提供整合式開發環境。Visual Studio 2017 provides an integrated development environment for .NET Core apps on Windows.

您可以在版本資訊中,進一步了解 Visual Studio 2017 的變更。You can read more about the changes in Visual Studio 2017 in the release notes.

若要在 Visual Studio 2017 中開發使用 .NET Core 2.2 SDK 的 .NET Core 應用程式:To develop .NET Core apps in Visual Studio 2017 using the .NET Core 2.2 SDK:

  1. 下載並安裝 Visual Studio 2017 15.9.0 版本或更新版本,選取 [.NET Core 跨平台開發] 工作負載 (在 [其他工具組] 區段)。Download and install Visual Studio 2017 version 15.9.0 or higher with the .NET Core cross-platform development workload (in the Other Toolsets section) selected.

已選取 [.NET Core 跨平台開發] 工作負載的 Visual Studio 2017 安裝螢幕擷取畫面

安裝 .NET Core 跨平台開發工具集之後,Visual Studio 通常會安裝舊版的 .NET Core SDK。After the .NET Core cross-platform development toolset is installed, Visual Studio usually installs a previous version of the .NET Core SDK. 例如,安裝工作負載之後,Visual Studio 2017 15.9 預設會使用 .NET Core 2.1 SDK。For example, Visual Studio 2017 15.9 uses .NET Core 2.1 SDK by default after the workload is installed.

若要更新 Visual Studio 以使用 .NET Core 2.2 SDK:To update Visual Studio to use .NET Core 2.2 SDK:

  1. 安裝 .NET Core 2.2 SDKInstall the .NET Core 2.2 SDK.

  2. 如果您希望專案使用最新的 .NET Core 執行階段,請使用下列指示將現有或新的 .NET Core 專案目標重新設定為 .NET Core 2.2:If you want your project to use the latest .NET Core runtime, retarget existing or new .NET Core projects to .NET Core 2.2 using the following instructions:

    • 在 [ 專案 ] 功能表上,選擇 [ 屬性]。On the Project menu, choose Properties.
    • 在 [目標 Framework] 選取功能表中,將值設為 .NET Core 2.2In the Target framework selection menu, set the value to .NET Core 2.2.

螢幕擷取畫面:選取 ".NET Core 2.2" 目標 Framework 功能表項目的 Visual Studio 2017 應用程式專案屬性

一旦使用 .NET Core 2.2 SDK 設定 Visual Studio,您可以執行下列動作:Once you have Visual Studio configured with .NET Core 2.2 SDK, you can do the following actions:

  • 開啟、建置及執行現有的 .NET Core 1.x 和 2.x 專案。Open, build, and run existing .NET Core 1.x and 2.x projects.
  • 將 .NET Core 1.x 和 2.x 專案目標重新設定為 .NET Core 2.2、建置和執行。Retarget .NET Core 1.x and 2.x projects to .NET Core 2.2, build, and run.
  • 建立新的 .NET Core 2.2 專案。Create new .NET Core 2.2 projects.

提示

確認 Visual Studio 版本:To verify your Visual Studio version:

  • [說明] 功能表上,選擇 [關於 Microsoft Visual Studio]On the Help menu, choose About Microsoft Visual Studio.
  • 在 [關於 Microsoft Visual Studio] 對話方塊中,確認版本號碼。In the About Microsoft Visual Studio dialog, verify the version number.
    • 針對 .NET Core 3.0 Preview 3 應用程式,需要 Visual Studio 2019 16.0 版或更新版本。For .NET Core 3.0 Preview 3 apps, Visual Studio 2019 version 16.0 or higher.
    • 若為 .NET Core 2.2 應用程式,需要 Visual Studio 2017 15.9 版或更新版本。For .NET Core 2.2 apps, Visual Studio 2017 version 15.9 or higher.
    • 若為 .NET Core 2.1 應用程式,需要 Visual Studio 2017 15.7 版或更新版本。For .NET Core 2.1 apps, Visual Studio 2017 version 15.7 or higher.
    • 若為 .NET Core 1.x 應用程式,需要 Visual Studio 2017 版本 15.0 或更高版本。For .NET Core 1.x apps, Visual Studio 2017 version 15.0 or higher.